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.
00163 { 00164 bitsPerDigit = 1; 00165 }
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().
00176 { 00177 return OverlayKey::getLength() / bitsPerDigit 00178 - x.sharedPrefixLength(y, bitsPerDigit); 00179 }
void KeyPrefixMetric::setBitsPerDigit | ( | uint8_t | bitsPerDigit | ) | [inline] |
Definition at line 181 of file Comparator.h.
00182 { 00183 this->bitsPerDigit = bitsPerDigit; 00184 }
uint8_t KeyPrefixMetric::bitsPerDigit [private] |
Definition at line 187 of file Comparator.h.
Referenced by distance(), and KeyPrefixMetric().