FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
FIFE::QuadTree< DataType, MinimumSize > Class Template Reference

Dynamic QuadTree A space partitioning tree automatically expanding to adjust to any object size put into the data structure. More...

#include <quadtree.h>

+ Inheritance diagram for FIFE::QuadTree< DataType, MinimumSize >:
+ Collaboration diagram for FIFE::QuadTree< DataType, MinimumSize >:

Public Types

typedef QuadNode< DataType, MinimumSize > Node
 

Public Member Functions

 QuadTree (int32_t x=0, int32_t y=0, int32_t starting_size=MinimumSize)
 Create a new QuadTree. More...
 
 ~QuadTree ()
 
Nodefind_container (int32_t x, int32_t y, int32_t w, int32_t h)
 Find a container node for a given rectangle. More...
 
Nodefind_container (const Rect &rect)
 
template<typename Visitor >
Visitor & apply_visitor (Visitor &visitor)
 Apply a visitor recursively to the QuadTree. More...
 
void clear ()
 

Protected Attributes

Nodem_root
 
Nodem_cursor
 

Detailed Description

template<typename DataType, int32_t MinimumSize = 128>
class FIFE::QuadTree< DataType, MinimumSize >

Dynamic QuadTree A space partitioning tree automatically expanding to adjust to any object size put into the data structure.

Definition at line 150 of file quadtree.h.

Member Typedef Documentation

◆ Node

template<typename DataType, int32_t MinimumSize = 128>
typedef QuadNode<DataType,MinimumSize> FIFE::QuadTree< DataType, MinimumSize >::Node

Definition at line 152 of file quadtree.h.

Constructor & Destructor Documentation

◆ QuadTree()

template<typename DataType, int32_t MinimumSize = 128>
FIFE::QuadTree< DataType, MinimumSize >::QuadTree ( int32_t  x = 0,
int32_t  y = 0,
int32_t  starting_size = MinimumSize 
)
inline

Create a new QuadTree.

Parameters
xThe X position of the starting node.
yThe Y position of the starting node.
starting_sizeThe width and height of the starting node.

Definition at line 159 of file quadtree.h.

◆ ~QuadTree()

template<typename DataType, int32_t MinimumSize = 128>
FIFE::QuadTree< DataType, MinimumSize >::~QuadTree ( )
inline

Definition at line 164 of file quadtree.h.

Member Function Documentation

◆ apply_visitor()

template<typename DataType, int32_t MinimumSize = 128>
template<typename Visitor >
Visitor& FIFE::QuadTree< DataType, MinimumSize >::apply_visitor ( Visitor &  visitor)
inline

Apply a visitor recursively to the QuadTree.

Definition at line 190 of file quadtree.h.

Referenced by FIFE::InstanceTree::applyVisitor().

+ Here is the caller graph for this function:

◆ clear()

template<typename DataType, int32_t MinimumSize = 128>
void FIFE::QuadTree< DataType, MinimumSize >::clear ( void  )
inline

Definition at line 195 of file quadtree.h.

◆ find_container() [1/2]

template<typename DataType , int32_t MinimumSize>
QuadNode< DataType, MinimumSize > * FIFE::QuadTree< DataType, MinimumSize >::find_container ( int32_t  x,
int32_t  y,
int32_t  w,
int32_t  h 
)

Find a container node for a given rectangle.

This guarantees to return a Node with the following properties: 1.) The node contains the rectangle (as defined by the contains function). 2.) All subnodes can not contain the rectangle or it has the MinimumSize. This function will extend the tree automatically so that this guarantee can be fulfilled. This function is optimized for sequential access. This means accessing different rectangles that are 'near' to each other will be fast.

Warning
If you put different sized objects in (for example) lists in the quadnode, the returned node will not contain all objects which might intersect with the given rectangle.

Definition at line 359 of file quadtree.h.

Referenced by FIFE::InstanceTree::addInstance(), and FIFE::InstanceTree::findInstances().

+ Here is the caller graph for this function:

◆ find_container() [2/2]

template<typename DataType, int32_t MinimumSize = 128>
Node* FIFE::QuadTree< DataType, MinimumSize >::find_container ( const Rect rect)
inline

Definition at line 183 of file quadtree.h.

Member Data Documentation

◆ m_cursor

template<typename DataType, int32_t MinimumSize = 128>
Node* FIFE::QuadTree< DataType, MinimumSize >::m_cursor
protected

Definition at line 205 of file quadtree.h.

◆ m_root

template<typename DataType, int32_t MinimumSize = 128>
Node* FIFE::QuadTree< DataType, MinimumSize >::m_root
protected

Definition at line 204 of file quadtree.h.


The documentation for this class was generated from the following file: