21 #ifndef GF_RANDOM_BINARY_TREE_H 22 #define GF_RANDOM_BINARY_TREE_H 33 #ifndef DOXYGEN_SHOULD_SKIP_THIS 56 Node(
const RectI& area, std::size_t parent,
int level)
85 return m_left == 0 && m_right == 0;
132 return m_area.contains(position);
147 std::size_t m_parent;
160 using Callback = std::function<bool(const RandomBinaryTree&, const Node&)>;
185 const Node& getRoot()
const;
192 const Node& getLeftChild(
const Node& node)
const;
199 const Node& getRightChild(
const Node& node)
const;
208 const Node& getParent(
const Node& node)
const;
218 return getRoot().contains(position);
240 bool traversePreOrder(
Callback callback)
const;
249 bool traverseInOrder(
Callback callback)
const;
258 bool traversePostOrder(
Callback callback)
const;
269 bool traverseLevelOrder(
Callback callback)
const;
278 bool traverseInvertedLevelOrder(
Callback callback)
const;
281 std::vector<Node> m_nodes;
284 #ifndef DOXYGEN_SHOULD_SKIP_THIS 289 #endif // GF_RANDOM_BINARY_TREE_H A random engine.
Definition: Random.h:47
A random binary space partionning tree.
Definition: RandomBinaryTree.h:41
int getLevel() const
Get the level of the node in the tree.
Definition: RandomBinaryTree.h:73
bool contains(Vector2i position) const
Check if the area of the node contains a position.
Definition: RandomBinaryTree.h:131
std::size_t getLeftChildIndex() const
Get the left child's index.
Definition: RandomBinaryTree.h:104
std::function< bool(const RandomBinaryTree &, const Node &)> Callback
A callback function for traversing the tree.
Definition: RandomBinaryTree.h:160
The namespace for gf classes.
Definition: Action.h:35
bool contains(Vector2i position) const
Check if the tree contains a position.
Definition: RandomBinaryTree.h:217
bool isLeaf() const
Check if a node is a leaf.
Definition: RandomBinaryTree.h:84
A node of the random binary space partionning tree.
Definition: RandomBinaryTree.h:47
std::size_t getParentIndex() const
Get the parent's indes of the node.
Definition: RandomBinaryTree.h:95
void setChildrenIndices(std::size_t left, std::size_t right)
Set the children indices of the node.
Definition: RandomBinaryTree.h:141
std::size_t getRightChildIndex() const
Get the right child's index.
Definition: RandomBinaryTree.h:113
Node(const RectI &area, std::size_t parent, int level)
Constructor.
Definition: RandomBinaryTree.h:56
const RectI & getArea() const
Get the area of the node.
Definition: RandomBinaryTree.h:122