OverlayKey prefix metric. More...
#include <Comparator.h>
Public Member Functions | |
| KeyPrefixMetric () | |
| OverlayKey | distance (const OverlayKey &x, const OverlayKey &y) const |
| calculates the distance from x to y with the prefix metric | |
| void | setBitsPerDigit (uint8_t bitsPerDigit) |
Private Attributes | |
| uint8_t | bitsPerDigit |
OverlayKey prefix metric.
Definition at line 159 of file Comparator.h.
| KeyPrefixMetric::KeyPrefixMetric | ( | ) | [inline] |
Definition at line 162 of file Comparator.h.
{
bitsPerDigit = 1;
}
| OverlayKey KeyPrefixMetric::distance | ( | const OverlayKey & | x, | |
| const OverlayKey & | y | |||
| ) | const [inline] |
calculates the distance from x to y with the prefix metric
| x | origination key | |
| y | destination key |
Definition at line 174 of file Comparator.h.
Referenced by KademliaPRComparator::compare().
{
return OverlayKey::getLength() / bitsPerDigit
- x.sharedPrefixLength(y, bitsPerDigit);
}
| void KeyPrefixMetric::setBitsPerDigit | ( | uint8_t | bitsPerDigit | ) | [inline] |
Definition at line 181 of file Comparator.h.
{
this->bitsPerDigit = bitsPerDigit;
}
uint8_t KeyPrefixMetric::bitsPerDigit [private] |
Definition at line 187 of file Comparator.h.
Referenced by distance(), and KeyPrefixMetric().
1.7.1