KeyPrefixMetric Class Reference

OverlayKey prefix metric. More...

#include <Comparator.h>

List of all members.

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

Detailed Description

OverlayKey prefix metric.

Definition at line 159 of file Comparator.h.


Constructor & Destructor Documentation

KeyPrefixMetric::KeyPrefixMetric (  )  [inline]

Definition at line 162 of file Comparator.h.

00163     {
00164         bitsPerDigit = 1;
00165     }


Member Function Documentation

OverlayKey KeyPrefixMetric::distance ( const OverlayKey x,
const OverlayKey y 
) const [inline]

calculates the distance from x to y with the prefix metric

Parameters:
x origination key
y destination key
Returns:
|differing suffix|

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     }


Member Data Documentation

uint8_t KeyPrefixMetric::bitsPerDigit [private]

Definition at line 187 of file Comparator.h.

Referenced by distance(), and KeyPrefixMetric().


The documentation for this class was generated from the following file:
Generated on Wed May 26 16:21:18 2010 for OverSim by  doxygen 1.6.3