KeyDistanceComparator< KeyPrefixMetric > Class Template Reference

#include <Comparator.h>

Inheritance diagram for KeyDistanceComparator< KeyPrefixMetric >:

Comparator< OverlayKey >

List of all members.

template<>
class KeyDistanceComparator< KeyPrefixMetric >


Public Member Functions

 KeyDistanceComparator (const OverlayKey &relativeKey, uint 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

Private Attributes

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

Constructor & Destructor Documentation

KeyDistanceComparator< KeyPrefixMetric >::KeyDistanceComparator ( const OverlayKey relativeKey,
uint  bitsPerDigit = 1 
) [inline]

constructor

00211     {
00212         key = relativeKey;
00213         m.setBitsPerDigit(bitsPerDigit);
00214     }


Member Function Documentation

int KeyDistanceComparator< KeyPrefixMetric >::compare ( const OverlayKey lhs,
const OverlayKey rhs 
) const [inline, virtual]

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

Parameters:
lhs first key
rhs second 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 >.

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


Member Data Documentation

indicates which metric to use for the comparison

the relative key to which distances are compared


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

Generated on Fri Sep 19 13:05:07 2008 for ITM OverSim by  doxygen 1.5.5