Gamedev Framework (gf)  0.12.0
A C++14 framework for 2D games
Public Member Functions | List of all members
gf::RandomBinaryTree::Node Class Reference

A node of the random binary space partionning tree. More...

#include <gf/RandomBinaryTree.h>

Public Member Functions

 Node (const RectI &area, std::size_t parent, int level)
 Constructor. More...
 
int getLevel () const
 Get the level of the node in the tree. More...
 
bool isLeaf () const
 Check if a node is a leaf. More...
 
std::size_t getParentIndex () const
 Get the parent's indes of the node. More...
 
std::size_t getLeftChildIndex () const
 Get the left child's index. More...
 
std::size_t getRightChildIndex () const
 Get the right child's index. More...
 
const RectIgetArea () const
 Get the area of the node. More...
 
bool contains (Vector2i position) const
 Check if the area of the node contains a position. More...
 
void setChildrenIndices (std::size_t left, std::size_t right)
 Set the children indices of the node. More...
 

Detailed Description

A node of the random binary space partionning tree.

Constructor & Destructor Documentation

◆ Node()

gf::RandomBinaryTree::Node::Node ( const RectI area,
std::size_t  parent,
int  level 
)
inline

Constructor.

Parameters
areaThe area of the node
parentThe index of the parent node
levelThe level of the node

Member Function Documentation

◆ contains()

bool gf::RandomBinaryTree::Node::contains ( Vector2i  position) const
inline

Check if the area of the node contains a position.

Parameters
positionThe position to check

◆ getArea()

const RectI& gf::RandomBinaryTree::Node::getArea ( ) const
inline

Get the area of the node.

Returns
The area of the node

◆ getLeftChildIndex()

std::size_t gf::RandomBinaryTree::Node::getLeftChildIndex ( ) const
inline

Get the left child's index.

Returns
The left child's index if it exists or 0

◆ getLevel()

int gf::RandomBinaryTree::Node::getLevel ( ) const
inline

Get the level of the node in the tree.

The root of the tree is at level 0, its children at level 1, etc.

Returns
The level of the node

◆ getParentIndex()

std::size_t gf::RandomBinaryTree::Node::getParentIndex ( ) const
inline

Get the parent's indes of the node.

The root of the tree is its own parent.

Returns
The parent's index of the node

◆ getRightChildIndex()

std::size_t gf::RandomBinaryTree::Node::getRightChildIndex ( ) const
inline

Get the right child's index.

Returns
The right child's index if it exists or 0

◆ isLeaf()

bool gf::RandomBinaryTree::Node::isLeaf ( ) const
inline

Check if a node is a leaf.

A leaf has no children.

Returns
True if the node is a leaf

◆ setChildrenIndices()

void gf::RandomBinaryTree::Node::setChildrenIndices ( std::size_t  left,
std::size_t  right 
)
inline

Set the children indices of the node.

Parameters
leftThe index of the left child
rightThe index of the right child