Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Util.Collections
Class HashCodeComparator  view HashCodeComparator download HashCodeComparator.java

java.lang.Object
  extended byUtil.Collections.HashCodeComparator
All Implemented Interfaces:
java.util.Comparator

public class HashCodeComparator
extends java.lang.Object
implements java.util.Comparator

Version:
$Id: HashCodeComparator.java,v 1.2 2003/05/12 10:05:21 joewhaley Exp $

Field Summary
private  java.lang.Thread cleanupThread
           
private  java.util.List duplicate_hashcode_objects
           
static HashCodeComparator INSTANCE
           
private  java.lang.ref.ReferenceQueue queue
           
static boolean TEST
           
static boolean TRACE
           
static boolean USE_IDENTITY_HASHCODE
           
static boolean USE_WEAK_REFERENCES
           
 
Constructor Summary
HashCodeComparator()
           
 
Method Summary
 int compare(java.lang.Object arg0, java.lang.Object arg1)
          Return an integer that is negative, zero or positive depending on whether the first argument is less than, equal to or greater than the second according to this ordering.
 void finalize()
          Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed.
private  int indexOf(java.lang.Object o)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

USE_IDENTITY_HASHCODE

public static final boolean USE_IDENTITY_HASHCODE
See Also:
Constant Field Values

USE_WEAK_REFERENCES

public static final boolean USE_WEAK_REFERENCES
See Also:
Constant Field Values

INSTANCE

public static final HashCodeComparator INSTANCE

TRACE

public static final boolean TRACE
See Also:
Constant Field Values

TEST

public static final boolean TEST
See Also:
Constant Field Values

duplicate_hashcode_objects

private java.util.List duplicate_hashcode_objects

queue

private final java.lang.ref.ReferenceQueue queue

cleanupThread

private volatile java.lang.Thread cleanupThread
Constructor Detail

HashCodeComparator

public HashCodeComparator()
Method Detail

finalize

public void finalize()
Description copied from class: java.lang.Object
Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed. You would think that this means it eventually is called on every Object, but this is not necessarily the case. If execution terminates abnormally, garbage collection does not always happen. Thus you cannot rely on this method to always work. For finer control over garbage collection, use references from the java.lang.ref package.

Virtual Machines are free to not call this method if they can determine that it does nothing important; for example, if your class extends Object and overrides finalize to do simply super.finalize().

finalize() will be called by a java.lang.Thread that has no locks on any Objects, and may be called concurrently. There are no guarantees on the order in which multiple objects are finalized. This means that finalize() is usually unsuited for performing actions that must be thread-safe, and that your implementation must be use defensive programming if it is to always work.

If an Exception is thrown from finalize() during garbage collection, it will be patently ignored and the Object will still be destroyed.

It is allowed, although not typical, for user code to call finalize() directly. User invocation does not affect whether automatic invocation will occur. It is also permitted, although not recommended, for a finalize() method to "revive" an object by making it reachable from normal code again.

Unlike constructors, finalize() does not get called for an object's superclass unless the implementation specifically calls super.finalize().

The default implementation does nothing.


compare

public int compare(java.lang.Object arg0,
                   java.lang.Object arg1)
Description copied from interface: java.util.Comparator
Return an integer that is negative, zero or positive depending on whether the first argument is less than, equal to or greater than the second according to this ordering. This method should obey the following contract:
  • if compare(a, b) < 0 then compare(b, a) > 0
  • if compare(a, b) throws an exception, so does compare(b, a)
  • if compare(a, b) < 0 and compare(b, c) < 0 then compare(a, c) < 0
  • if compare(a, b) == 0 then compare(a, c) and compare(b, c) must have the same sign
To be consistent with equals, the following additional constraint is in place:
  • if a.equals(b) or both a and b are null, then compare(a, b) == 0.

Although it is permissible for a comparator to provide an order inconsistent with equals, that should be documented.

Specified by:
compare in interface java.util.Comparator

indexOf

private int indexOf(java.lang.Object o)