|
entttree 0.1.0
Hierarchical entity management for EnTT
|
A fractional index with strong ordering, used for sibling positioning. More...
#include <position.h>
Public Types | |
| using | symbol_t = uint8_t |
Public Member Functions | |
| Position () | |
| Construct a Position at the midpoint (0.5). | |
| Position (const Position &other) | |
| Position (Position &&other) | |
| Position & | operator= (const Position &other) |
| Position & | operator= (Position &&other) |
| std::strong_ordering | operator<=> (const Position &other) const |
| Lexicographic three-way comparison. | |
| bool | operator== (const Position &other) const |
| Position | before () const |
| Return a position immediately before this one. | |
| Position | between (const Position &other) const |
Return a position midway between this position and other. | |
| Position | after () const |
| Return a position immediately after this one. | |
| size_t | byte_count () const |
| Number of symbols in the fractional-index representation. | |
| const symbol_t * | bytes () const |
| Read-only pointer to the raw symbol bytes (big-endian, high-order first). | |
Static Public Member Functions | |
| static Position | from_bytes (const symbol_t *data, size_t count) |
| Construct a Position from raw symbol bytes. | |
Protected Member Functions | |
| symbol_t * | _data () |
| const symbol_t * | _data () const |
| symbol_t | operator[] (size_t i) const |
Friends | |
| template<typename T , typename H > | |
| struct | geom::Digest |
A fractional index with strong ordering, used for sibling positioning.
This is an infinite-precision number between 0 and 1 exclusive, represented as a base-256 value with unlimited digits right of the decimal point. The leading zero is not stored.
Chunking into 8-bit symbols balances two growth pressures: large symbols reduce growth from sequential before()/after() calls (~128 steps before a new symbol is needed), while the between() operation grows the number only when the last symbols of the two positions are within 1 of each other.
Up to 14 symbols (112 bits) are stored inline; beyond that, heap storage is used. Default-constructed positions start at the midpoint (0.5).
Definition at line 27 of file position.h.
Definition at line 28 of file position.h.
| entttree::Position::Position | ( | ) |
Construct a Position at the midpoint (0.5).
Definition at line 49 of file position.cpp.
Referenced by from_bytes().
Definition at line 53 of file position.cpp.
| entttree::Position::Position | ( | Position && | other | ) |
Definition at line 67 of file position.cpp.
| entttree::Position::~Position | ( | ) |
Definition at line 79 of file position.cpp.
|
protected |
Definition at line 10 of file position.cpp.
|
protected |
Definition at line 14 of file position.cpp.
| Position entttree::Position::after | ( | ) | const |
Return a position immediately after this one.
Definition at line 140 of file position.cpp.
References entttree::and.
| Position entttree::Position::before | ( | ) | const |
Return a position immediately before this one.
Definition at line 160 of file position.cpp.
References entttree::and.
Return a position midway between this position and other.
The result is always strictly between the two operands regardless of their ordering. The representation may grow by one symbol when the two positions are adjacent.
Definition at line 178 of file position.cpp.
|
inline |
Number of symbols in the fractional-index representation.
Definition at line 94 of file position.h.
|
inline |
Read-only pointer to the raw symbol bytes (big-endian, high-order first).
Definition at line 97 of file position.h.
Construct a Position from raw symbol bytes.
| data | Pointer to symbol bytes (big-endian, high-order first). |
| count | Number of symbols. Must be >= 1. |
Definition at line 208 of file position.cpp.
References Position().
Lexicographic three-way comparison.
Definition at line 123 of file position.cpp.
Definition at line 88 of file position.cpp.
Definition at line 104 of file position.cpp.
Definition at line 74 of file position.h.
|
protected |
Definition at line 18 of file position.cpp.
Definition at line 41 of file position.h.
| symbol_t* entttree::Position::_symbol_ptr |
Heap pointer when size exceeds K.
Definition at line 46 of file position.h.
| symbol_t entttree::Position::_symbols[K] |
Inline storage for small positions.
Definition at line 45 of file position.h.