My Project: dht::indexation::Prefix Class Reference

My Project 3.7.7 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:
[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 31 of file pht.h.

## Constructor & Destructor Documentation

## ◆ Prefix() [1/4]

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

Definition at line 33 of file pht.h.

## ◆ Prefix() [2/4]

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

Definition at line 34 of file pht.h.

## ◆ Prefix() [3/4]

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

Definition at line 38 of file pht.h.

## ◆ Prefix() [4/4]

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

Definition at line 44 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 163 of file pht.h.

## ◆ commonBits()

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

This method count total of bit in common between 2 prefix

Parameters

  p1 | first prefix to compared
  p2 | second prefix to compared

Returns
  Lenght of the larger common prefix between both

Definition at line 124 of file pht.h.

## ◆ getFullSize()

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

Definition at line 94 of file pht.h.

## ◆ getPrefix()

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

Get a sub prefix of the Prefix

Parameters

  len | lenght 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_range | if len is larger than size of the content

Definition at line 71 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 101 of file pht.h.

## ◆ hash()

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

Definition at line 110 of file pht.h.

## ◆ isContentBitActive()

bool dht::indexation::Prefix::isContentBitActive | ( | size_t | pos | ) | const
| inline

See also
  isActiveBit in private function

Definition at line 92 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 87 of file pht.h.

## ◆ swapContentBit()

void dht::indexation::Prefix::swapContentBit | ( | size_t | bit | ) |
| inline

See also
  doc of swap private function

Definition at line 153 of file pht.h.

## ◆ swapFlagBit()

void dht::indexation::Prefix::swapFlagBit | ( | size_t | bit | ) |
| inline

See also
  doc of swap private function

Definition at line 158 of file pht.h.

## ◆ updateFlags()

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

Definition at line 165 of file pht.h.

## Member Data Documentation

## ◆ content_

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

Definition at line 191 of file pht.h.

## ◆ flags_

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

Definition at line 190 of file pht.h.

## ◆ size_

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

Definition at line 185 of file pht.h.

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

- /home/noptrix/ba/blackarch/packages/opendht-c/src/opendht/include/opendht/indexation/pht.h