Class UComp<T>

  extended by jpaul.Misc.UComp<T>
All Implemented Interfaces:

public class UComp<T>
extends java.lang.Object
implements java.util.Comparator<T>

UComp is an universal comparator, which compares any two objecs by simply comparing 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.

$Id:,v 1.3 2006/03/14 02:29:31 salcianu Exp $
Alexandru Salcianu -

Constructor Summary
Method Summary
 int compare(T o1, T o2)
          Compares its two arguments for order.
 boolean equals(java.lang.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

Constructor Detail


public UComp()
Method Detail


public int compare(T o1,
                   T 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 java.util.Comparator<T>


public boolean equals(java.lang.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 java.util.Comparator<T>
equals in class java.lang.Object

Copyright 2005 Alexandru Salcianu -