Javolution 6.0.0 java
javolution.util.function.Equality< T > Interface Template Reference
Inheritance diagram for javolution.util.function.Equality< T >:
[legend]
Collaboration diagram for javolution.util.function.Equality< T >:
[legend]

Public Member Functions

int hashCodeOf (T object)
 
boolean areEqual (T left, T right)
 
int compare (T left, T right)
 

Detailed Description

A comparator to be used for element equality as well as for ordering. Implementing classes should ensure that:

  • The compare function is consistent with equals. If two objects compare to
    0
    then they are equals and the the reciprocal is true (this ensures that sorted collections/maps do not break the general contract of their parent class based on object equal).
  • The hashcode function is consistent with equals: If two objects are equals, they have the same hashcode (the reciprocal is not true).
  • The
    null
    value is supported (even for comparisons) and the hashcode value of
    null
    is
    0
    .
Parameters
<T>the type of objects that may be compared for equality or order.
Author
Jean-Marie Dautelle
Version
6.0, July 21, 2013
See also
Equalities

Definition at line 39 of file Equality.java.

Member Function Documentation

◆ areEqual()

boolean javolution.util.function.Equality< T >.areEqual ( left,
right 
)

Indicates if the specified objects can be considered equal. This methods is equivalent to

(compare(o1, o2) == 0)

but usually faster.

Parameters
leftthe first object (or null).
rightthe second object (or null).
Returns
true if both objects are considered equal; false otherwise.

Referenced by javolution.util.internal.map.MapView< K, V >.EntryComparator.areEqual(), javolution.util.internal.collection.CollectionView< R >.contains(), javolution.util.internal.collection.CollectionView< R >.equals(), javolution.util.internal.table.TableView< E >.indexOf(), javolution.util.internal.table.TableView< E >.lastIndexOf(), javolution.util.internal.map.FastMapImpl< K, V >.remove(), javolution.util.internal.collection.CollectionView< R >.remove(), and javolution.util.internal.map.FastMapImpl< K, V >.replace().

Here is the caller graph for this function:

◆ compare()

int javolution.util.function.Equality< T >.compare ( left,
right 
)

Compares the specified objects for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, possibly equal to, or greater than the second. Implementation classes should ensure that comparisons with

null

is supported.

Parameters
leftthe first object.
rightthe second object.
Returns
a negative integer, zero, or a positive integer as the first argument is less than, possibly equal to, or greater than the second.

Referenced by javolution.util.internal.set.sorted.SubSortedSetImpl< E >.add(), javolution.util.internal.map.MapView< K, V >.EntryComparator.compare(), javolution.text.CharArray.compareTo(), javolution.text.Text.compareTo(), javolution.util.internal.set.sorted.SubSortedSetImpl< E >.contains(), javolution.util.internal.map.sorted.SubSortedMapImpl< K, V >.containsKey(), javolution.util.internal.map.sorted.SubSortedMapImpl< K, V >.get(), javolution.util.internal.set.sorted.SubSortedSetImpl< E >.IteratorImpl.hasNext(), javolution.util.internal.map.sorted.SubSortedMapImpl< K, V >.IteratorImpl.hasNext(), javolution.util.internal.map.sorted.SubSortedMapImpl< K, V >.put(), javolution.util.internal.set.sorted.SubSortedSetImpl< E >.remove(), and javolution.util.internal.map.sorted.SubSortedMapImpl< K, V >.remove().

Here is the caller graph for this function:

◆ hashCodeOf()

int javolution.util.function.Equality< T >.hashCodeOf ( object)

Returns the hash code for the specified object (consistent with areEqual). Two objects considered equal have the same hash code. The hash code of null is always 0.

Parameters
objectthe object to return the hashcode for.
Returns
the hashcode for the specified object.

Referenced by javolution.util.internal.map.FastMapImpl< K, V >.containsKey(), javolution.util.internal.map.FastMapImpl< K, V >.get(), javolution.util.internal.collection.CollectionView< R >.hashCode(), javolution.util.internal.map.MapView< K, V >.EntryComparator.hashCodeOf(), javolution.util.internal.map.FastMapImpl< K, V >.put(), javolution.util.internal.map.FastMapImpl< K, V >.putIfAbsent(), javolution.util.internal.map.FastMapImpl< K, V >.remove(), and javolution.util.internal.map.FastMapImpl< K, V >.replace().

Here is the caller graph for this function:

The documentation for this interface was generated from the following file:
javolution.util.function.Equality.compare
int compare(T left, T right)