C++ Distributed Hash Table
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
dht::indexation::Prefix Class Reference

A blob structure which prefixes a Key in the PHT. More...

#include <pht.h>

Collaboration diagram for dht::indexation::Prefix:
Collaboration graph
[legend]

Public Member Functions

 Prefix (InfoHash h)
 
 Prefix (const Blob &d, const Blob &f={})
 
 Prefix (const Prefix &p, size_t first)
 
Prefix getPrefix (ssize_t len) const
 
bool isFlagActive (size_t pos) const
 
bool isContentBitActive (size_t pos) const
 
Prefix getFullSize ()
 
Prefix getSibling () const
 
InfoHash hash () const
 
void swapContentBit (size_t bit)
 
void swapFlagBit (size_t bit)
 
void addPaddingContent (size_t size)
 
void updateFlags ()
 
std::string toString () const
 

Static Public Member Functions

static unsigned commonBits (const Prefix &p1, const Prefix &p2)
 

Public Attributes

size_t size_ {0}
 
Blob flags_ {}
 
Blob content_ {}
 

Detailed Description

A blob structure which prefixes a Key in the PHT.

Since the PHT structure is a "trie", every node in this structure have a label which is defined by the path from the root of the trie to the node. If the node in question is a leaf, the label is a prefix of all the keys contained in the leaf.

Definition at line 49 of file pht.h.

Member Function Documentation

◆ addPaddingContent()

void dht::indexation::Prefix::addPaddingContent ( size_t  size)
inline
See also
doc of addPadding private function

Definition at line 181 of file pht.h.

◆ commonBits()

static unsigned dht::indexation::Prefix::commonBits ( const Prefix p1,
const Prefix p2 
)
inlinestatic

This method count total of bit in common between 2 prefix

Parameters
p1first prefix to compared
p2second prefix to compared
Returns
Lenght of the larger common prefix between both

Definition at line 136 of file pht.h.

◆ getPrefix()

Prefix dht::indexation::Prefix::getPrefix ( ssize_t  len) const
inline

Get a sub prefix of the Prefix

Parameters
lenlenght of the prefix to get, could be negative if len is negativ then you will get the prefix of size of the previous prefix minus len
Returns
Sub-prefix of size len or if len is negative sub-prefix of size of prefix minus len
Exceptions
out_of_rangeif len is larger than size of the content

Definition at line 82 of file pht.h.

◆ getSibling()

Prefix dht::indexation::Prefix::getSibling ( ) const
inline

This methods gets the prefix of its sibling in the PHT structure.

Returns
The prefix of this sibling.

Definition at line 115 of file pht.h.

◆ isContentBitActive()

bool dht::indexation::Prefix::isContentBitActive ( size_t  pos) const
inline
See also
isActiveBit in private function

Definition at line 104 of file pht.h.

◆ isFlagActive()

bool dht::indexation::Prefix::isFlagActive ( size_t  pos) const
inline

Flags are considered as active if flag is empty or if the flag at pos 'pos' is active ee *

See also
isActiveBit in private function

Definition at line 97 of file pht.h.

◆ swapContentBit()

void dht::indexation::Prefix::swapContentBit ( size_t  bit)
inline
See also
doc of swap private function

Definition at line 167 of file pht.h.

◆ swapFlagBit()

void dht::indexation::Prefix::swapFlagBit ( size_t  bit)
inline
See also
doc of swap private function

Definition at line 174 of file pht.h.


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