20#ifndef RIPPLE_SHAMAP_TAGGEDPOINTER_H_INCLUDED 
   21#define RIPPLE_SHAMAP_TAGGEDPOINTER_H_INCLUDED 
   23#include <xrpl/basics/IntrusivePointer.h> 
   24#include <xrpl/shamap/SHAMapTreeNode.h> 
   64        "Bad alignment: Tag pointer requires low two bits to be zero.");
 
 
  223[[nodiscard]] 
inline int 
  228#elif defined(__clang__) || defined(__GNUC__) 
  229    return __builtin_popcount(a);
 
  232    static auto constexpr const tbl = []() {
 
  234        for (
int i = 0; i != 256; ++i)
 
  236            for (
int j = 0; j != 8; ++j)
 
  244    return tbl[a & 0xff] + tbl[a >> 8];
 
 
A shared intrusive pointer class that supports weak pointers.
 
TaggedPointer is a combination of a pointer and a mask stored in the lowest two bits.
 
void iterNonEmptyChildIndexes(std::uint16_t isBranch, F &&f) const
Call the f callback for all non-empty branches.
 
std::pair< std::uint8_t, void * > decode() const
Decode the tagged pointer into its tag and pointer.
 
TaggedPointer(TaggedPointer &&other, std::uint16_t srcBranches, std::uint16_t dstBranches, std::uint8_t toAllocate)
Given other with the specified children in srcBranches, create a new TaggedPointer with the allocated...
 
TaggedPointer(TaggedPointer &&)
 
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).
 
TaggedPointer(TaggedPointer const &)=delete
 
void destroyHashesAndChildren()
Deallocate memory and run destructors.
 
TaggedPointer(TaggedPointer &&other, std::uint16_t isBranch, std::uint8_t toAllocate)
Constructor is used change the number of allocated children.
 
std::tuple< std::uint8_t, SHAMapHash *, intr_ptr::SharedPtr< SHAMapTreeNode > * > getHashesAndChildren() const
Get the number of elements in each array and a pointer to the start of each array.
 
static constexpr std::uintptr_t tagMask
bit-and with this mask to get the tag bits (lowest two bits)
 
SHAMapHash * getHashes() const
Get the hashes array.
 
TaggedPointer & operator=(TaggedPointer &&)
 
static constexpr std::uintptr_t ptrMask
bit-and with this mask to get the pointer bits (mask out the tag)
 
std::uint8_t capacity() const
Get the number of elements allocated for each array.
 
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(RawAllocateTag, std::uint8_t numChildren)
This constructor allocates space for the hashes and children, but does not run constructors.
 
void iterChildren(std::uint16_t isBranch, F &&f) const
Call the f callback for all 16 (branchFactor) branches - even if the branch is empty.
 
bool isDense() const
Check if the arrays have a dense format.
 
TaggedPointer(std::uint8_t numChildren)
 
intr_ptr::SharedPtr< SHAMapTreeNode > * getChildren() const
Get the children array.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
int popcnt16(std::uint16_t a)