BWAPI
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions
Util::RegionQuadTree< Type > Class Template Reference

#include <RegionQuadTree.h>

List of all members.

Public Member Functions

 RegionQuadTree (unsigned int width=1, unsigned int height=1)
 ~RegionQuadTree (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)

Detailed Description

template<class Type>
class Util::RegionQuadTree< Type >

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.


Constructor & Destructor Documentation

template<class Type >
Util::RegionQuadTree< Type >::RegionQuadTree ( unsigned int  width = 1,
unsigned int  height = 1 
)

Creates the quad tree with the specified dimensions.

Parameters:
widthWidth of the highest detail level partition.
heightHeight of the highest detail level partition.

Here is the call graph for this function:

template<class Type >
Util::RegionQuadTree< Type >::~RegionQuadTree ( void  )

Destorys the array, but doesn't delete inserted objects.


Member Function Documentation

template<class Type >
void Util::RegionQuadTree< Type >::addItem ( unsigned int  x,
unsigned int  y,
Type *  item 
)

Sets item of the array on the specified position.

Parameters:
xhorizontal index of the array position.
yvertical index of the array position.
itemnew value of the field.
template<class Type >
void Util::RegionQuadTree< Type >::clear ( unsigned int  x,
unsigned int  y 
)
template<class Type >
unsigned int Util::RegionQuadTree< Type >::getHeight ( void  ) const

Gets the height of the array.

Returns:
height of the array.
template<class Type >
std::list<Type*>* Util::RegionQuadTree< Type >::getItems ( unsigned int  x,
unsigned int  y,
unsigned int  level = 0 
)

Gets list of items in the specified region.

Parameters:
xhorizontal index of the region.
yvertical index of the region.
Returns:
list of items on the specified region
template<class Type >
unsigned int Util::RegionQuadTree< Type >::getWidth ( void  ) const

Gets the width of the array.

Returns:
width of the array.

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines