java.lang.Object
net.i2p.router.web.helpers.HashComparator
- All Implemented Interfaces:
Serializable, Comparator<Hash>
Sorts in true binary order, not Base64 string order. A-Z a-z 0-9 -~.
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HashComparatorShared stateless instance of the comparator.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic intOrders two hashes by their raw data bytes, statically.intOrders two hashes by their raw data bytes.static HashComparatorThread safe, no state.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
Field Details
_instance
Shared stateless instance of the comparator.
Constructor Details
HashComparator
HashComparator()Constructor. The ordering is fixed by the hash byte layout, so an instance holds no state and the shared _instance below is used instead.
Method Details
getInstance
Thread safe, no state.- Returns:
- the shared comparator, which holds no state
compare
Orders two hashes by their raw data bytes.- Specified by:
comparein interfaceComparator<Hash>
comp
Orders two hashes by their raw data bytes, statically.- Parameters:
l- left-hand Hash, compared through its raw data bytesr- right-hand Hash, compared through its raw data bytes- Returns:
- negative, zero or positive as l's bytes are less than, equal to, or greater than r's