Zip and Skip Tries
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Related Symbols | List of all members
MemoryEfficientLCP Struct Reference

Represents an approximate Longest Common Prefix (LCP) length in a memory-efficient format. More...

#include <ZipTrie.hpp>

Public Member Functions

auto operator<=> (const MemoryEfficientLCP &) const =default
 Default comparison operator.
 
unsigned value () const noexcept
 Calculates the approximate actual LCP value represented by this struct.
 
std::ostream & print (std::ostream &os) const noexcept
 Prints the LCP representation (e.g., "2^3 * 5") to an output stream.
 

Public Attributes

uint8_t exp_of_2 = 0
 The exponent part of the LCP representation (base 2).
 
uint8_t multiple = 0
 The multiple (mantissa) part of the LCP representation.
 

Related Symbols

(Note that these are not member symbols.)

std::ostream & operator<< (std::ostream &os, const MemoryEfficientLCP &lcp)
 Overloaded stream insertion operator (<<) for MemoryEfficientLCP.
 

Detailed Description

Represents an approximate Longest Common Prefix (LCP) length in a memory-efficient format.

Stores the LCP value approximately as multiple * 2^exp_of_2. This allows representing potentially large LCP values using fewer bits (typically two uint8_t) at the cost of precision for larger values. The scaling depends on the expected maximum size of the trie.

See also
ZipTrie::get_memory_efficient_lcp

Definition at line 36 of file ZipTrie.hpp.

Member Function Documentation

◆ operator<=>()

auto MemoryEfficientLCP::operator<=> ( const MemoryEfficientLCP ) const
default

Default comparison operator.

Compares exp_of_2 first, then multiple for tie-breaking. This allows comparing approximate LCP values directly.

◆ print()

std::ostream & MemoryEfficientLCP::print ( std::ostream &  os) const
inlinenoexcept

Prints the LCP representation (e.g., "2^3 * 5") to an output stream.

Parameters
osThe output stream to write to.
Returns
std::ostream& Reference to the output stream after writing.

Definition at line 1062 of file ZipTrie.hpp.

1063{
1064 // Cast uint8_t to unsigned for correct stream output as numbers.
1065 return os << "2^" << static_cast<unsigned>(exp_of_2) << "*" << static_cast<unsigned>(multiple);
1066}
T * alloc_to_device(size_t size)
Allocates memory on the CUDA device.
uint8_t multiple
The multiple (mantissa) part of the LCP representation.
Definition ZipTrie.hpp:41
uint8_t exp_of_2
The exponent part of the LCP representation (base 2).
Definition ZipTrie.hpp:39

◆ value()

unsigned MemoryEfficientLCP::value ( ) const
inlinenoexcept

Calculates the approximate actual LCP value represented by this struct.

Returns
unsigned The calculated LCP value (multiple * 2^exp_of_2).

Definition at line 1055 of file ZipTrie.hpp.

1056{
1057 // Calculate the value by left-shifting 1 by exp_of_2 and multiplying by multiple.
1058 // Ensure intermediate shift doesn't overflow if exp_of_2 is large, though unlikely for uint8_t.
1059 return (1u << exp_of_2) * multiple;
1060}

Friends And Related Symbol Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const MemoryEfficientLCP lcp 
)
related

Overloaded stream insertion operator (<<) for MemoryEfficientLCP.

Allows printing MemoryEfficientLCP objects directly to output streams (e.g., std::cout << lcp;). Delegates formatting to the MemoryEfficientLCP::print method.

Parameters
osThe output stream (e.g., std::cout, std::ofstream).
lcpThe MemoryEfficientLCP object to print.
Returns
std::ostream& Reference to the output stream after printing.

Definition at line 1077 of file ZipTrie.hpp.

1078{
1079 // Delegate the actual printing logic to the struct's print method.
1080 return lcp.print(os);
1081}
std::ostream & print(std::ostream &os) const noexcept
Prints the LCP representation (e.g., "2^3 * 5") to an output stream.
Definition ZipTrie.hpp:1062

Member Data Documentation

◆ exp_of_2

uint8_t MemoryEfficientLCP::exp_of_2 = 0

The exponent part of the LCP representation (base 2).

Definition at line 39 of file ZipTrie.hpp.

◆ multiple

uint8_t MemoryEfficientLCP::multiple = 0

The multiple (mantissa) part of the LCP representation.

Definition at line 41 of file ZipTrie.hpp.


The documentation for this struct was generated from the following file: