Public Member Functions

StdProxComparator Class Reference

#include <Comparator.h>

Inheritance diagram for StdProxComparator:
AbstractProxComparator

List of all members.

Public Member Functions

int compare (const Prox &lhs, const Prox &rhs) const
 indicates which of the two given proximities is "better"

Detailed Description

Definition at line 271 of file Comparator.h.


Member Function Documentation

int StdProxComparator::compare ( const Prox lhs,
const Prox rhs 
) const [inline, virtual]

indicates which of the two given proximities is "better"

Parameters:
lhs first proximity value
rhs second 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 274 of file Comparator.h.

Referenced by KademliaPRComparator::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: