Antkeeper
0.0.1
|
Hashed linear hyperoctree. More...
#include <hyperoctree.hpp>
Public Types | |
typedef T | node_type |
Node identifier type. More... | |
typedef hyperoctree_container< order, node_type, depth_bits >::type | container_type |
Node container type. More... | |
typedef container_type::iterator | iterator |
Iterator type. More... | |
typedef container_type::const_iterator | const_iterator |
Constant iterator type. More... | |
typedef std::conditional< order !=hyperoctree_order::unordered, std::reverse_iterator< iterator >, iterator >::type | reverse_iterator |
Reverse iterator type. More... | |
typedef std::conditional< order !=hyperoctree_order::unordered, std::reverse_iterator< const_iterator >, const_iterator >::type | const_reverse_iterator |
Constant reverse iterator type. More... | |
Public Member Functions | |
hyperoctree () | |
Constructs a hyperoctree with a single root node. More... | |
Iterators | |
iterator | begin () noexcept |
Returns an iterator to the first node, in the traversal order specified by hyperoctree::order. More... | |
const_iterator | begin () const noexcept |
Returns an iterator to the first node, in the traversal order specified by hyperoctree::order. More... | |
const_iterator | cbegin () const noexcept |
Returns an iterator to the first node, in the traversal order specified by hyperoctree::order. More... | |
iterator | end () noexcept |
Returns an iterator to the node following the last node, in the traversal order specified by hyperoctree::order. More... | |
const_iterator | end () const noexcept |
Returns an iterator to the node following the last node, in the traversal order specified by hyperoctree::order. More... | |
const_iterator | cend () const noexcept |
Returns an iterator to the node following the last node, in the traversal order specified by hyperoctree::order. More... | |
reverse_iterator | rbegin () noexcept |
Returns a reverse iterator to the first node of the revered hyperoctree, in the traversal order specified by hyperoctree::order. More... | |
const_reverse_iterator | rbegin () const noexcept |
Returns a reverse iterator to the first node of the revered hyperoctree, in the traversal order specified by hyperoctree::order. More... | |
const_reverse_iterator | crbegin () const noexcept |
Returns a reverse iterator to the first node of the revered hyperoctree, in the traversal order specified by hyperoctree::order. More... | |
reverse_iterator | rend () noexcept |
Returns a reverse iterator to the node following the last node of the reverse hyperoctree, in the traversal order specified by hyperoctree::order. More... | |
const_reverse_iterator | rend () const noexcept |
Returns a reverse iterator to the node following the last node of the reverse hyperoctree, in the traversal order specified by hyperoctree::order. More... | |
const_reverse_iterator | crend () const noexcept |
Returns a reverse iterator to the node following the last node of the reverse hyperoctree, in the traversal order specified by hyperoctree::order. More... | |
Capacity | |
bool | empty () const noexcept |
Checks if the hyperoctree has no nodes. More... | |
bool | full () const noexcept |
Checks if the hyperoctree is full. More... | |
std::size_t | size () const noexcept |
Returns the number of nodes in the hyperoctree. More... | |
constexpr std::size_t | max_size () const noexcept |
Returns the total number of nodes the hyperoctree is capable of containing. More... | |
Modifiers | |
void | clear () |
Erases all nodes except the root node, which is persistent. More... | |
void | insert (node_type node) |
Inserts a node and its siblings into the hyperoctree, inserting ancestors as necessary. More... | |
void | erase (node_type node) |
Erases a node, along with its descendants, siblings, and descendants of siblings. More... | |
Lookup | |
bool | contains (node_type node) const |
Checks if a node is contained within the hyperoctree. More... | |
bool | is_leaf (node_type node) const |
Checks if a node has no children. More... | |
Static Public Member Functions | |
Nodes | |
static constexpr node_type | depth (node_type node) noexcept |
Extracts the depth of a node from its identifier. More... | |
static constexpr node_type | location (node_type node) noexcept |
Extracts the Morton location code of a node from its identifier. More... | |
static constexpr std::array< node_type, 2 > | split (node_type node) noexcept |
Extracts the depth and Morton location code of a node from its identifier. More... | |
static constexpr node_type | node (node_type depth, node_type location) noexcept |
Constructs an identifier for a node at the given depth and location. More... | |
static constexpr node_type | ancestor (node_type node, node_type depth) noexcept |
Constructs an identifier for the ancestor of a node at a given depth. More... | |
static constexpr node_type | parent (node_type node) noexcept |
Constructs an identifier for the parent of a node. More... | |
static constexpr node_type | sibling (node_type node, node_type n) noexcept |
Constructs an identifier for the nth sibling of a node. More... | |
static constexpr node_type | child (node_type node, T n) noexcept |
Constructs an identifier for the nth child of a node. More... | |
static constexpr node_type | common_ancestor (node_type a, node_type b) noexcept |
Constructs an identifier for the first common ancestor of two nodes. More... | |
Static Public Attributes | |
static constexpr std::size_t | dimensions = N |
Number of dimensions. More... | |
static constexpr hyperoctree_order | order = Order |
Node storage and traversal order. More... | |
static constexpr node_type | max_depth = find_max_depth() |
Maximum node depth level. More... | |
static constexpr node_type | node_bits = sizeof(node_type) * 8 |
Number of bits in the node type. More... | |
static constexpr node_type | depth_bits = std::bit_width(max_depth) |
Number of bits required to encode the depth of a node. More... | |
static constexpr node_type | location_bits = (max_depth + 1) * N |
Number of bits required to encode the Morton location code of a node. More... | |
static constexpr node_type | divider_bits = node_bits - (depth_bits + location_bits) |
Number of bits separating the depth and Morton location code in a node identifier. More... | |
static constexpr node_type | children_per_node = math::compile::exp2<node_type>(N) |
Number of children per node. More... | |
static constexpr node_type | siblings_per_node = children_per_node - 1 |
Number of siblings per node. More... | |
static constexpr node_type | resolution = math::compile::exp2<node_type>(max_depth) |
Resolution in each dimension. More... | |
static constexpr std::size_t | max_node_count = (math::compile::pow<std::size_t>(resolution * 2, N) - 1) / siblings_per_node |
Number of nodes in a full hyperoctree. More... | |
static constexpr node_type | root = 0 |
Node identifier of the persistent root node. More... | |
Hashed linear hyperoctree.
T | Unsigned integral node identifier type. |
N | Number of dimensions. |
Order | Order in which nodes are stored and traversed. |
Definition at line 98 of file hyperoctree.hpp.
typedef container_type::const_iterator geom::hyperoctree< T, N, Order >::const_iterator |
Constant iterator type.
Definition at line 190 of file hyperoctree.hpp.
typedef std::conditional<order != hyperoctree_order::unordered, std::reverse_iterator<const_iterator>, const_iterator>::type geom::hyperoctree< T, N, Order >::const_reverse_iterator |
Constant reverse iterator type.
Definition at line 196 of file hyperoctree.hpp.
typedef hyperoctree_container<order, node_type, depth_bits>::type geom::hyperoctree< T, N, Order >::container_type |
Node container type.
Definition at line 184 of file hyperoctree.hpp.
typedef container_type::iterator geom::hyperoctree< T, N, Order >::iterator |
Iterator type.
Definition at line 187 of file hyperoctree.hpp.
typedef T geom::hyperoctree< T, N, Order >::node_type |
Node identifier type.
Definition at line 145 of file hyperoctree.hpp.
typedef std::conditional<order != hyperoctree_order::unordered, std::reverse_iterator<iterator>, iterator>::type geom::hyperoctree< T, N, Order >::reverse_iterator |
Reverse iterator type.
Definition at line 193 of file hyperoctree.hpp.
|
inline |
Constructs a hyperoctree with a single root node.
Definition at line 329 of file hyperoctree.hpp.
|
inlinestaticconstexprnoexcept |
Constructs an identifier for the ancestor of a node at a given depth.
node | Node identifier. |
depth | Absolute depth of an ancestor node. |
depth
exceeds the depth of node
, the returned node identifier is not valid. Definition at line 264 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns an iterator to the first node, in the traversal order specified by hyperoctree::order.
Definition at line 345 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns an iterator to the first node, in the traversal order specified by hyperoctree::order.
Definition at line 341 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns an iterator to the first node, in the traversal order specified by hyperoctree::order.
Definition at line 349 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns an iterator to the node following the last node, in the traversal order specified by hyperoctree::order.
Definition at line 369 of file hyperoctree.hpp.
|
inlinestaticconstexprnoexcept |
Constructs an identifier for the nth child of a node.
node | Node identifier. |
n | Offset to a sibling of the first child node, automatically wrapped to [0, siblings_per_node] . |
Definition at line 306 of file hyperoctree.hpp.
|
inline |
Erases all nodes except the root node, which is persistent.
Definition at line 484 of file hyperoctree.hpp.
|
inlinestaticconstexprnoexcept |
Constructs an identifier for the first common ancestor of two nodes.
a | Identifier of the first node. |
b | Identifier of the second node. |
Definition at line 319 of file hyperoctree.hpp.
|
inline |
Checks if a node is contained within the hyperoctree.
node | Identifier of the node to check for. |
true
if the hyperoctree contains the node, false
otherwise. Definition at line 549 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the first node of the revered hyperoctree, in the traversal order specified by hyperoctree::order.
Definition at line 396 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the node following the last node of the reverse hyperoctree, in the traversal order specified by hyperoctree::order.
Definition at line 426 of file hyperoctree.hpp.
|
inlinestaticconstexprnoexcept |
Extracts the depth of a node from its identifier.
node | Node identifier. |
Definition at line 207 of file hyperoctree.hpp.
|
inlinenoexcept |
Checks if the hyperoctree has no nodes.
true
if the hyperoctree is empty, false
otherwise.false
, as the root node is persistent. Definition at line 445 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns an iterator to the node following the last node, in the traversal order specified by hyperoctree::order.
Definition at line 365 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns an iterator to the node following the last node, in the traversal order specified by hyperoctree::order.
Definition at line 361 of file hyperoctree.hpp.
|
inline |
Erases a node, along with its descendants, siblings, and descendants of siblings.
node | Identifier of the node to erase. |
Definition at line 519 of file hyperoctree.hpp.
|
inlinenoexcept |
Checks if the hyperoctree is full.
true
if the hyperoctree is full, false
otherwise. Definition at line 455 of file hyperoctree.hpp.
|
inline |
Inserts a node and its siblings into the hyperoctree, inserting ancestors as necessary.
node | Node to insert. |
Definition at line 496 of file hyperoctree.hpp.
|
inline |
Checks if a node has no children.
node | Node identififer. |
true
if the node has no children, and false
otherwise. Definition at line 561 of file hyperoctree.hpp.
|
inlinestaticconstexprnoexcept |
Extracts the Morton location code of a node from its identifier.
node | Node identifier. |
Definition at line 220 of file hyperoctree.hpp.
|
inlineconstexprnoexcept |
Returns the total number of nodes the hyperoctree is capable of containing.
Definition at line 473 of file hyperoctree.hpp.
|
inlinestaticconstexprnoexcept |
Constructs an identifier for a node at the given depth and location.
depth | Depth level. |
location | Morton location code. |
depth
exceeds max_depth
, the returned node identifier is not valid. Definition at line 249 of file hyperoctree.hpp.
|
inlinestaticconstexprnoexcept |
Constructs an identifier for the parent of a node.
node | Node identifier. |
Definition at line 277 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the first node of the revered hyperoctree, in the traversal order specified by hyperoctree::order.
Definition at line 389 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the first node of the revered hyperoctree, in the traversal order specified by hyperoctree::order.
Definition at line 382 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the node following the last node of the reverse hyperoctree, in the traversal order specified by hyperoctree::order.
Definition at line 419 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the node following the last node of the reverse hyperoctree, in the traversal order specified by hyperoctree::order.
Definition at line 412 of file hyperoctree.hpp.
|
inlinestaticconstexprnoexcept |
Constructs an identifier for the nth sibling of a node.
node | Node identifier. |
n | Offset to a sibling, automatically wrapped to [0, siblings_per_node] . |
Definition at line 290 of file hyperoctree.hpp.
|
inlinenoexcept |
Returns the number of nodes in the hyperoctree.
Definition at line 467 of file hyperoctree.hpp.
|
inlinestaticconstexprnoexcept |
Extracts the depth and Morton location code of a node from its identifier.
node | Node identifier. |
Definition at line 232 of file hyperoctree.hpp.
|
staticconstexpr |
Number of children per node.
Definition at line 169 of file hyperoctree.hpp.
|
staticconstexpr |
Number of bits required to encode the depth of a node.
Definition at line 160 of file hyperoctree.hpp.
|
staticconstexpr |
Number of dimensions.
Definition at line 148 of file hyperoctree.hpp.
|
staticconstexpr |
Number of bits separating the depth and Morton location code in a node identifier.
Definition at line 166 of file hyperoctree.hpp.
|
staticconstexpr |
Number of bits required to encode the Morton location code of a node.
Definition at line 163 of file hyperoctree.hpp.
|
staticconstexpr |
Maximum node depth level.
Definition at line 154 of file hyperoctree.hpp.
|
staticconstexpr |
Number of nodes in a full hyperoctree.
Definition at line 178 of file hyperoctree.hpp.
|
staticconstexpr |
Number of bits in the node type.
Definition at line 157 of file hyperoctree.hpp.
|
staticconstexpr |
Node storage and traversal order.
Definition at line 151 of file hyperoctree.hpp.
|
staticconstexpr |
Resolution in each dimension.
Definition at line 175 of file hyperoctree.hpp.
|
staticconstexpr |
Node identifier of the persistent root node.
Definition at line 181 of file hyperoctree.hpp.
|
staticconstexpr |
Number of siblings per node.
Definition at line 172 of file hyperoctree.hpp.