|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.drools.util.FastComparator
public abstract class FastComparator
This class represents a comparator to be used for equality as well as
for ordering; instances of this class provide a hashcode function
consistent with equal (if two objects are equal
, they have the same hashcode
),
equality with null
values is supported.
FastComparator
can be employed with FastMap
(e.g. custom
key comparators for identity maps, value retrieval using keys of a
different class that the map keys) or with FastCollection
classes.
Field Summary | |
---|---|
static FastComparator |
DEFAULT
Holds the default object comparator; rehash is performed if the system hash code (platform dependent) is not evenly distributed. |
static FastComparator |
DIRECT
Holds the direct object comparator; no rehash is performed. |
static FastComparator |
IDENTITY
Holds the identity comparator; poorly distributed system hashcodes are rehashed. |
static FastComparator |
LEXICAL
Holds a lexicographic comparator for any CharSequence or
String instances. |
static FastComparator |
REHASH
Holds the comparator for objects with uneven hash distribution; objects hashcodes are rehashed. |
static boolean |
REHASH_SYSTEM_HASHCODE
Indicates if the system hash code should be rehashed (see Javolution Configuration for details). |
Constructor Summary | |
---|---|
FastComparator()
|
Method Summary | |
---|---|
abstract boolean |
areEqual(java.lang.Object o1,
java.lang.Object o2)
Indicates if the specified objects can be considered equal. |
abstract int |
compare(java.lang.Object o1,
java.lang.Object o2)
Compares the specified objects for order. |
abstract int |
hashCodeOf(java.lang.Object obj)
Returns the hash code for the specified object (consistent with areEqual(java.lang.Object, java.lang.Object) ). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
---|
equals |
Field Detail |
---|
public static final boolean REHASH_SYSTEM_HASHCODE
public static final FastComparator DEFAULT
public static final FastComparator DIRECT
equal
if and
only if o1.equals(o2)
. The compare(java.lang.Object, java.lang.Object)
method
throws ClassCastException
if the specified objects are not
Comparable
.
public static final FastComparator REHASH
equal
if and only if o1.equals(o2)
.
The compare(java.lang.Object, java.lang.Object)
method throws ClassCastException
if the
specified objects are not Comparable
.
public static final FastComparator IDENTITY
equal
if and only if (o1 == o2)
. The compare(java.lang.Object, java.lang.Object)
method
throws ClassCastException
if the specified objects are not
Comparable
.
public static final FastComparator LEXICAL
CharSequence
or
String
instances.
Two objects are considered equal
if and only if they
represents the same character sequence). The hashcode is calculated
using the following formula (same as for java.lang.String
):
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
Constructor Detail |
---|
public FastComparator()
Method Detail |
---|
public abstract int hashCodeOf(java.lang.Object obj)
areEqual(java.lang.Object, java.lang.Object)
). Two objects considered equal
have
the same hash code.
obj
- the object to return the hashcode for.
java.lang.NullPointerException
- if the specified object is
null
.public abstract boolean areEqual(java.lang.Object o1, java.lang.Object o2)
o1
- the first object (or null
).o2
- the second object (or null
).
true
if both objects are considered equal;
false
otherwise.public abstract int compare(java.lang.Object o1, java.lang.Object o2)
compare
in interface java.util.Comparator
o1
- the first object.o2
- the second object.
java.lang.NullPointerException
- if any of the specified object is
null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |