OverSim
KeyDistanceComparator< Metric > Class Template Reference

OverlayKey distance comparator. More...

#include <Comparator.h>

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

Public Member Functions

 KeyDistanceComparator (const OverlayKey &relativeKey)
 constructor
int compare (const OverlayKey &lhs, const OverlayKey &rhs) const
 indicates which of the two given keys is closer to the relative key
- Public Member Functions inherited from Comparator< OverlayKey >
virtual ~Comparator ()
 virtual destructor

Private Attributes

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

Detailed Description

template<class Metric = KeyStdMetric>
class KeyDistanceComparator< Metric >

OverlayKey distance comparator.

Definition at line 215 of file Comparator.h.

Constructor & Destructor Documentation

template<class Metric = KeyStdMetric>
KeyDistanceComparator< Metric >::KeyDistanceComparator ( const OverlayKey relativeKey)
inline

constructor

Definition at line 225 of file Comparator.h.

{
this->key = relativeKey;
}

Member Function Documentation

template<class Metric = KeyStdMetric>
int KeyDistanceComparator< Metric >::compare ( const OverlayKey lhs,
const OverlayKey rhs 
) const
inlinevirtual

indicates which of the two given keys is closer 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 239 of file Comparator.h.

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

Member Data Documentation

template<class Metric = KeyStdMetric>
Metric KeyDistanceComparator< Metric >::m
private

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