|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Defines comparison methods useable to impose a total ordering on a collection of objects.
The ordering you can produce with these methods is the class's
natural ordering, and the class's implementation of
compare is its natural comparison method.
| Method Summary | ||
int |
compare(Object o1,
Object o2)
Compares two arguments for order. |
|
boolean |
equals(Object obj)
Determines if provided object is equal to this one. |
|
| Method Detail |
public int compare(Object o1, Object o2)
o1 - First object to compare.o2 - Second object to compare.ClassCastException - If this comparator cannot compare the two
objects.public boolean equals(Object obj)
This method must obey the general contract of
Object.equals(Object).
Additionally, this method can return true only if the provided
object also implements this interface and imposes the same ordering as this
comparator. Thus, comp1.equals(comp2) implies that
sgn(comp1.compare(o1, o2))==sgn(comp2.compare(o1, o2)) for
every object reference o1 and o2.
Note that it is always safe not to override
Object.equals(Object). However, overriding this method may,
in some cases, improve performance by allowing programs to determine
that two distinct comparators impose the same order.
obj - Object to compare with this comparator.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2007 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.