Class RationalComparator<A>

java.lang.Object
eu.bandm.tools.ops.RationalComparator<A>
All Implemented Interfaces:
Comparator<A>

public class RationalComparator<A> extends Object implements 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 Details

    • RationalComparator

      public RationalComparator(@Opt @Opt Comparator<? super A> base)
      Only constructor, setting the underlying comparator.
  • Method Details

    • compare

      public int compare(A a, A b)
      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:
      compare in interface Comparator<A>
    • getCache

      Map<A,Double> getCache()
      Return the current mapping from domain objects to rational representations.