OverSim
KeyDistanceComparator< KeyPrefixMetric > Class Template Reference

#include <Comparator.h>

Inheritance diagram for KeyDistanceComparator< KeyPrefixMetric >:
Comparator< OverlayKey >

Public Member Functions

 KeyDistanceComparator (const OverlayKey &relativeKey, uint32_t bitsPerDigit=1)
 constructor
int compare (const OverlayKey &lhs, const OverlayKey &rhs) const
 indicates which of the two given keys has a longer distance to the relative key
- Public Member Functions inherited from Comparator< OverlayKey >
virtual ~Comparator ()
 virtual destructor

Private Attributes

KeyPrefixMetric m
 indicates which metric to use for the comparison
OverlayKey key
 the relative key to which distances are compared

Detailed Description

template<>
class KeyDistanceComparator< KeyPrefixMetric >

Definition at line 246 of file Comparator.h.

Constructor & Destructor Documentation

KeyDistanceComparator< KeyPrefixMetric >::KeyDistanceComparator ( const OverlayKey relativeKey,
uint32_t  bitsPerDigit = 1 
)
inline

constructor

Definition at line 256 of file Comparator.h.

{
key = relativeKey;
m.setBitsPerDigit(bitsPerDigit);
}

Member Function Documentation

int KeyDistanceComparator< KeyPrefixMetric >::compare ( const OverlayKey lhs,
const OverlayKey rhs 
) const
inlinevirtual

indicates which of the two given keys has a longer distance to the relative key

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

Reimplemented from Comparator< OverlayKey >.

Definition at line 270 of file Comparator.h.

{
return m.distance(lhs, key).compareTo(m.distance(rhs, key));
}

Member Data Documentation

the relative key to which distances are compared

Definition at line 250 of file Comparator.h.

indicates which metric to use for the comparison

Definition at line 249 of file Comparator.h.


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