OverSim
KademliaPRComparator Class Reference

#include <Comparator.h>

Inheritance diagram for KademliaPRComparator:
ProxKeyComparator< KeyPrefixMetric > AbstractProxKeyComparator

Public Member Functions

 KademliaPRComparator (const OverlayKey &relativeKey, uint32_t bitsPerDigit=1)
int compare (const ProxKey &lhs, const ProxKey &rhs) const
 indicates which of the two given prox/key-pairs is closer to the relative key
- Public Member Functions inherited from ProxKeyComparator< KeyPrefixMetric >
 ProxKeyComparator (const OverlayKey &relativeKey, uint32_t bitsPerDigit=1)
 constructor
- Public Member Functions inherited from AbstractProxKeyComparator
virtual ~AbstractProxKeyComparator ()

Additional Inherited Members

- Protected Attributes inherited from ProxKeyComparator< KeyPrefixMetric >
KeyPrefixMetric m
 indicates which metric to use for the key comparison
StdProxComparator pc
OverlayKey key
 the relative key to which distances are compared

Detailed Description

Definition at line 361 of file Comparator.h.

Constructor & Destructor Documentation

KademliaPRComparator::KademliaPRComparator ( const OverlayKey relativeKey,
uint32_t  bitsPerDigit = 1 
)
inline

Definition at line 364 of file Comparator.h.

Member Function Documentation

int KademliaPRComparator::compare ( const ProxKey lhs,
const ProxKey rhs 
) const
inlinevirtual

indicates which of the two given prox/key-pairs is closer to the relative key

Parameters
lhsfirst prox/key-pair
rhssecond prox/key-pair
Returns
-1 if lhs is closer, 0 if lhs and rhs are equal and 1 if rhs closer to the relative key

Implements AbstractProxKeyComparator.

Definition at line 367 of file Comparator.h.

{
int temp = m.distance(lhs.key, key).compareTo(m.distance(rhs.key, key));
if (temp != 0) {
return temp;
}
return pc.compare(lhs.prox, rhs.prox);
}

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