messif.buckets.index
Interface IndexComparator<K,O>

Type Parameters:
K - the type of the key arguments of the comparison
O - the type of the object arguments of the comparison
All Superinterfaces:
java.util.Comparator<K>, java.io.Serializable
All Known Subinterfaces:
OperationIndexComparator<K>
All Known Implementing Classes:
LocalAbstractObjectOrder

public interface IndexComparator<K,O>
extends java.io.Serializable, java.util.Comparator<K>

A comparison function, which imposes a total ordering on some collection of keys. Objects stored in the index are compared using keys for ordering; the extractKey(O) extracts a key for this comparator from any indexed object.

See Also:
Comparator

Method Summary
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this comparator.
 K extractKey(O object)
          Returns the key (used for comparison) from an indexed object.
 int indexCompare(K k, O o)
          Compares its two arguments for order.
 
Methods inherited from interface java.util.Comparator
compare
 

Method Detail

indexCompare

int indexCompare(K k,
                 O o)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Parameters:
k - the key to compare
o - the object to be compared
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
Throws:
java.lang.ClassCastException - if the arguments' types prevent them from being compared by this comparator.

extractKey

K extractKey(O object)
Returns the key (used for comparison) from an indexed object.

Parameters:
object - the indexed (full) object
Returns:
the extracted key

equals

boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this comparator. This method must obey the general contract of Object.equals(Object). Additionally, this method can return true only if the specified object is also a comparator and it imposes the same ordering as this comparator. Thus, comp1.equals(comp2) implies that sgn(comp1.indexCompare(o1, o2))==sgn(comp2.indexCompare(o1, o2)) for every object reference o1 and o2.

Note that it is always safe not to override Object.equals(Object). However, overriding this method may, in some cases, improve performance by allowing programs to determine that two distinct comparators impose the same order.

Specified by:
equals in interface java.util.Comparator<K>
Overrides:
equals in class java.lang.Object
Parameters:
obj - the reference object with which to compare.
Returns:
true only if the specified object is also a comparator and it imposes the same ordering as this comparator.
See Also:
Object.equals(Object), Object.hashCode()