20 #ifndef RIPPLE_SHAMAP_TAGGEDPOINTER_H_INCLUDED
21 #define RIPPLE_SHAMAP_TAGGEDPOINTER_H_INCLUDED
23 #include <ripple/shamap/SHAMapTreeNode.h>
61 "Bad alignment: Tag pointer requires low two bits to be zero.");
172 tuple<std::uint8_t, SHAMapHash*, std::shared_ptr<SHAMapTreeNode>*>
std::optional< int > getChildIndex(std::uint16_t isBranch, int i) const
Get the child's index inside the hashes or children array (which may or may not be sparse).
std::uintptr_t tp_
Upper bits are the pointer, lowest two bits are the tag A moved-from object will have a tp_ of zero.
TaggedPointer is a combination of a pointer and a mask stored in the lowest two bits.
TaggedPointer & operator=(TaggedPointer &&)
SHAMapHash * getHashes() const
Get the hashes array.
bool isDense() const
Check if the arrays have a dense format.
std::pair< std::uint8_t, void * > decode() const
Decode the tagged pointer into its tag and pointer.
void destroyHashesAndChildren()
Deallocate memory and run destructors.
void iterNonEmptyChildIndexes(std::uint16_t isBranch, F &&f) const
Call the f callback for all non-empty branches.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
static constexpr std::uintptr_t ptrMask
bit-and with this mask to get the pointer bits (mask out the tag)
std::shared_ptr< SHAMapTreeNode > * getChildren() const
Get the children array.
void iterChildren(std::uint16_t isBranch, F &&f) const
Call the f callback for all 16 (branchFactor) branches - even if the branch is empty.
std::tuple< std::uint8_t, SHAMapHash *, std::shared_ptr< SHAMapTreeNode > * > getHashesAndChildren() const
Get the number of elements in each array and a pointer to the start of each array.
std::uint8_t capacity() const
Get the number of elements allocated for each array.
static constexpr std::uintptr_t tagMask
bit-and with this mask to get the tag bits (lowest two bits)