[an error occurred while processing this directive]
In this sub-project, you will implement two classes:
This variation of a quadtree is similar to a binary search tree; however, rather than sorting on just one well-ordered element, it sorts on a pair of well-ordered elements. That is, it stores two-dimensional vectors which we will denote as (x, y) and each node has up to four children.
Quadtree |
---|
- root:Quadtree_node - count:Integer |
+ create():Quadtree + size():Integer + empty():Boolean + min_x():Type + min_y():Type + max_x():Type + max_y():Type + sum_x():Type + sum_y():Type + root():Quadtree_node + member( in x:Type, in y:Type ):Boolean + insert( in x:Type, in y:Type ) + clear() + destroy() |
This class stores a finite collection of n (zero or more) pairs (x,y) stored in nodes. If there are zero elements in the quadtree, the quadtree is said to be empty. Each pair is stored in an instance of the Quadtree_node<Type> class. If the quadtree is empty, the root is assigned 0. Otherwise, the root pointer stores the address of the root node.
The two member variables are:
Quadtree()
This constructor sets all class members to 0. (O(1))
The destructor must delete each of the nodes in the quadtree. (O(n))
This class has ten accessors:
The first two member functions should be implemented in the Quadtree class; the other member functions should call the appropriate member functions of the root node.
This class has two mutators: