org.graffiti.util
Class ObjectReferenceComparator<T>

java.lang.Object
  extended by org.graffiti.util.ObjectReferenceComparator<T>
All Implemented Interfaces:
Comparator<T>

public class ObjectReferenceComparator<T>
extends Object
implements Comparator<T>

The ObjectReferenceComparator guarantees to impose a total ordering for every type T. The objects are primarily ordered by their hash code. If for some objects a and b, a.hashCode() == b.hashCode(), but a != b, these objects are held in a LinkedList and ordered by their position in that list. Different instances of ObjectReferenceComparator may impose different total orderings. The objects are only weakly referenced from the list, so that having been compared by this comparator does not prevent them from being finalized by the garbage collector.

Version:
$Revision$ $Date$
Author:
Andreas Gleißner
See Also:
WeakReference

Constructor Summary
ObjectReferenceComparator()
           
 
Method Summary
 int compare(T arg0, T arg1)
          Compares its two arguments by their hashcode or, if both arguments share the same hashcode, by their position in a LinkedList maintained by this comparator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

ObjectReferenceComparator

public ObjectReferenceComparator()
Method Detail

compare

public int compare(T arg0,
                   T arg1)
Compares its two arguments by their hashcode or, if both arguments share the same hashcode, by their position in a LinkedList maintained by this comparator.

Specified by:
compare in interface Comparator<T>
Parameters:
arg0 - the first object to be compared.
arg1 - the second object to be compared.


Generated at 2012-05-30 11:00:14 PM CEST