OverSim
StdProxComparator Class Reference

#include <Comparator.h>

Inheritance diagram for StdProxComparator:
AbstractProxComparator

Public Member Functions

int compare (const Prox &lhs, const Prox &rhs) const
 indicates which of the two given proximities is "better"
- Public Member Functions inherited from AbstractProxComparator
virtual ~AbstractProxComparator ()

Detailed Description

Definition at line 292 of file Comparator.h.

Member Function Documentation

int StdProxComparator::compare ( const Prox lhs,
const Prox rhs 
) const
inlinevirtual

indicates which of the two given proximities is "better"

Parameters
lhsfirst proximity value
rhssecond proximity value
Returns
-1 if lhs is closer, 0 if lhs and rhs are equal and 1 if rhs closer

Implements AbstractProxComparator.

Definition at line 295 of file Comparator.h.

Referenced by KademliaPRComparator::compare(), and AccordionPRComparator::compare().

{
// return 0 if accuracy is too low
if (lhs.accuracy < 0.5 || rhs.accuracy < 0.5) return 0;
if (lhs.proximity < rhs.proximity) return -1;
if (lhs.proximity > rhs.proximity) return 1;
return 0;
}

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