harpoon.Util
Class UComp

java.lang.Object
  extended by harpoon.Util.UComp
All Implemented Interfaces:
Comparator

public class UComp
extends Object
implements Comparator

UComp is an universal comparator, which compares any two objecs by simply compraing their string representation. It is useful when you need a deterministic string representation of a set (for debug purposes). As sets don't have any ordering info, two equal sets could have different representations; instead you can convert the set to an array of elements, sort it with the help of this universal comparator and print it.

Version:
$Id: UComp.java,v 1.2 2002/02/25 21:08:55 cananian Exp $
Author:
Alexandru SALCIANU <salcianu@retezat.lcs.mit.edu>

Field Summary
static UComp uc
           
 
Constructor Summary
UComp()
           
 
Method Summary
 int compare(Object o1, Object o2)
          Compares its two arguments for order.
 boolean equals(Object obj)
          Indicates whether some other object is "equal" to" this Comparator.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uc

public static UComp uc
Constructor Detail

UComp

public UComp()
Method Detail

compare

public int compare(Object o1,
                   Object o2)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the string representation of the first argument is less than, equal to, or greater to the string representation of the second.

Specified by:
compare in interface Comparator

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal" to" this Comparator. The easiest implementation: always return false unless obj == this .

Specified by:
equals in interface Comparator
Overrides:
equals in class Object