Package eu.bandm.tools.util
Class RationalComparator<A>
java.lang.Object
eu.bandm.tools.util.RationalComparator<A>
- All Implemented Interfaces:
Comparator<A>
A cache for a given comparator, probably expensive to execute.
It learns comparation results and
memorizes them by mapping them to ratonal representations.
The current implementation uses floating point numbers and re-calculates the ratonal representations as soon as the precision is exhausted.
-
Constructor Summary
ConstructorsConstructorDescriptionRationalComparator(Comparator<? super A> base) Only constructor, setting the underlying comparator. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
RationalComparator
Only constructor, setting the underlying comparator.
-
-
Method Details
-
compare
Central sevice point: compare two objects. Both objects are first trnaslated into rational hash numbers, using the cache stores, which are then compared.- Specified by:
comparein interfaceComparator<A>
-
getCache
Return the current mapping from domain objects to rational representations.
-