Javolution 6.0.0 java
javolution.util.internal.comparator.WrapperComparatorImpl< E > Class Template Reference
Inheritance diagram for javolution.util.internal.comparator.WrapperComparatorImpl< E >:
[legend]
Collaboration diagram for javolution.util.internal.comparator.WrapperComparatorImpl< E >:
[legend]

Public Member Functions

 WrapperComparatorImpl (Comparator<? super E > comparator)
 
int hashCodeOf (E obj)
 
boolean areEqual (E e1, E e2)
 
int compare (E left, E right)
 
int hashCodeOf (T object)
 
boolean areEqual (T left, T right)
 
int compare (T left, T right)
 

Private Attributes

final Comparator<? super E > comparator
 

Static Private Attributes

static final long serialVersionUID = 8775282553794347279L
 

Detailed Description

A comparator service wrapping a {@ link Comparator}, since consistency with hashcode cannot be maintained. The hashcode calculation method throws UnsupportedOperationException.

Definition at line 21 of file WrapperComparatorImpl.java.

Constructor & Destructor Documentation

◆ WrapperComparatorImpl()

Member Function Documentation

◆ areEqual() [1/2]

boolean javolution.util.internal.comparator.WrapperComparatorImpl< E >.areEqual ( e1,
e2 
)

Definition at line 40 of file WrapperComparatorImpl.java.

40  {
41  return (e1 == e2) || (e1 != null && (comparator.compare(e1, e2) == 0));
42  }

References javolution.util.internal.comparator.WrapperComparatorImpl< E >.comparator.

◆ areEqual() [2/2]

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

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() [1/2]

int javolution.util.internal.comparator.WrapperComparatorImpl< E >.compare ( left,
right 
)

Definition at line 45 of file WrapperComparatorImpl.java.

45  {
46  if (left == right)
47  return 0;
48  if (left == null)
49  return -1;
50  if (right == null)
51  return 1;
52  return comparator.compare(left, right);
53  }

References javolution.util.internal.comparator.WrapperComparatorImpl< E >.comparator.

◆ compare() [2/2]

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

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() [1/2]

Definition at line 32 of file WrapperComparatorImpl.java.

32  {
33  throw new UnsupportedOperationException(
34  "Standard comparator (java.util.Comparator) cannot be used for "
35  + "hashcode calculations; please use a coherent equality comparator "
36  + "instead (e.g. javolution.util.function.Equality).");
37  }

◆ hashCodeOf() [2/2]

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

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:

Member Data Documentation

◆ comparator

◆ serialVersionUID

final long javolution.util.internal.comparator.WrapperComparatorImpl< E >.serialVersionUID = 8775282553794347279L
staticprivate

Definition at line 24 of file WrapperComparatorImpl.java.


The documentation for this class was generated from the following file:
javolution.util.internal.comparator.WrapperComparatorImpl.compare
int compare(E left, E right)
Definition: WrapperComparatorImpl.java:45
javolution.util.internal.comparator.WrapperComparatorImpl.comparator
final Comparator<? super E > comparator
Definition: WrapperComparatorImpl.java:25