java.lang.Object
net.i2p.router.peermanager.InverseCapacityComparator
- All Implemented Interfaces:
Serializable, Comparator<PeerProfile>
Order profiles by their capacity, but backwards (highest capacity / value first).
Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionintcompare(PeerProfile left, PeerProfile right) Compare the two objects backwards.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Comparator
equals, max, min, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
Constructor Details
InverseCapacityComparator
InverseCapacityComparator()Constructor. The ordering is read from the two profiles passed tocompare(PeerProfile, PeerProfile)and is fully determined, so an instance holds no state.
Method Details
compare
Compare the two objects backwards. The standard comparator returns -1 if lhs is less than rhs, 1 if lhs is greater than rhs, or 0 if they're equal. To keep a strict ordering, we measure peers with equal capacity values according to their speed.- Specified by:
comparein interfaceComparator<PeerProfile>- Returns:
- -1 if the right hand side is smaller, 1 if the left hand side is smaller, or 0 if they are the same peer (
Comparator.compare(T, T)inverted)