BWAPI
|
#include <QuadTree.h>
Public Member Functions | |
QuadTree (unsigned int width=1, unsigned int height=1) | |
~QuadTree (void) | |
unsigned int | getWidth (void) const |
unsigned int | getHeight (void) const |
std::list< Type * > * | getItems (unsigned int x, unsigned int y, unsigned int level=0) |
void | addItem (unsigned int x, unsigned int y, Type *item) |
void | clear (unsigned int x, unsigned int y) |
Structure representing 2D space containing objects of the specified type. This structure is optimised for effective way of finding of objects in certain area. The top level of the structure contains single list of all objects included, it divides into 2-4 partitions containing lists of units on respective quoters of the space, and so on until sthe width/height size is reached. The structure works with list of pointers of the type and doesn't act as owner, so removing items or deleting the whole quad tree will not result in delatation of contained items.
Util::QuadTree< Type >::QuadTree | ( | unsigned int | width = 1 , |
unsigned int | height = 1 |
||
) |
Creates the quad tree with the specified dimensions.
width | Width of the highest detail level partition. |
height | Height of the highest detail level partition. |
Util::QuadTree< Type >::~QuadTree | ( | void | ) |
Destorys the array, but doesn't delete inserted objects.
void Util::QuadTree< Type >::addItem | ( | unsigned int | x, |
unsigned int | y, | ||
Type * | item | ||
) |
Sets item of the array on the specified position.
x | horizontal index of the array position. |
y | vertical index of the array position. |
item | new value of the field. |
void Util::QuadTree< Type >::clear | ( | unsigned int | x, |
unsigned int | y | ||
) |
unsigned int Util::QuadTree< Type >::getHeight | ( | void | ) | const |
Gets the height of the array.
std::list<Type*>* Util::QuadTree< Type >::getItems | ( | unsigned int | x, |
unsigned int | y, | ||
unsigned int | level = 0 |
||
) |
Gets list of items in the specified region.
x | horizontal index of the region. |
y | vertical index of the region. |
unsigned int Util::QuadTree< Type >::getWidth | ( | void | ) | const |
Gets the width of the array.