My Project 3.2.0
C++ Distributed Hash Table
Loading...
Searching...
No Matches
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.

Constructor & Destructor Documentation

◆ Prefix() [1/4]

dht::indexation::Prefix::Prefix ( )
inline

Definition at line 50 of file pht.h.

◆ Prefix() [2/4]

dht::indexation::Prefix::Prefix ( InfoHash h)
inline

Definition at line 51 of file pht.h.

◆ Prefix() [3/4]

dht::indexation::Prefix::Prefix ( const Blob & d,
const Blob & f = {} )
inline

Definition at line 52 of file pht.h.

◆ Prefix() [4/4]

dht::indexation::Prefix::Prefix ( const Prefix & p,
size_t first )
inline

Definition at line 54 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.

◆ getFullSize()

Prefix dht::indexation::Prefix::getFullSize ( )
inline

Definition at line 108 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.

◆ hash()

InfoHash dht::indexation::Prefix::hash ( ) const
inline

Definition at line 123 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.

◆ updateFlags()

void dht::indexation::Prefix::updateFlags ( )
inline

Definition at line 185 of file pht.h.

Member Data Documentation

◆ content_

Blob dht::indexation::Prefix::content_ {}

Definition at line 210 of file pht.h.

◆ flags_

Blob dht::indexation::Prefix::flags_ {}

Definition at line 209 of file pht.h.

◆ size_

size_t dht::indexation::Prefix::size_ {0}

Definition at line 204 of file pht.h.


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