jdsl.core.ref
Class ByteArrayComparator
java.lang.Object
|
+--jdsl.core.ref.AbstractComparator
|
+--jdsl.core.ref.ByteArrayComparator
- All Implemented Interfaces:
- Comparator, EqualityComparator
- Direct Known Subclasses:
- LexicographicalByteArrayComparator
- public abstract class ByteArrayComparator
- extends AbstractComparator
- implements Comparator
Superclass for all byte array comparator implementations.
All subclasses should implement only compare(byte[],byte[]).
Subclasses define ordering of byte arrays.
- Version:
- $Id: ByteArrayComparator.java,v 1.2 2001/11/27 17:56:13 lv Exp $
- Author:
- Benety Goh (bg@cs.brown.edu), Luca Vismara (lv)
Method Summary |
abstract int |
compare(byte[] a,
byte[] b)
Compares two byte arrays. |
int |
compare(java.lang.Object a,
java.lang.Object b)
A C-style comparison function that returns a negative value if the
first object is less than the second, a positive value if the second
object is less, and 0 if the two objects are equal. |
boolean |
isComparable(java.lang.Object o)
Allows a container (or any client) to find out whether an object is
a member of the ordered set over which this comparator is defined. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ByteArrayComparator
public ByteArrayComparator()
compare
public abstract int compare(byte[] a,
byte[] b)
- Compares two byte arrays. Consistency constraints based on
compare() method of Comparator interface.
- Parameters:
a
- first byte array.b
- first byte array.- Returns:
- 0 if a and b are equal, < 0 if a < b, > 0 if a > b.
isComparable
public final boolean isComparable(java.lang.Object o)
- Description copied from interface:
EqualityComparator
- Allows a container (or any client) to find out whether an object is
a member of the ordered set over which this comparator is defined.
- Specified by:
isComparable
in interface EqualityComparator
- Following copied from interface:
jdsl.core.api.EqualityComparator
- Parameters:
o
- Any java.lang.Object- Returns:
- True if and only if this comparator may compare this object.
compare
public final int compare(java.lang.Object a,
java.lang.Object b)
throws java.lang.ClassCastException
- Description copied from interface:
Comparator
- A C-style comparison function that returns a negative value if the
first object is less than the second, a positive value if the second
object is less, and 0 if the two objects are equal.
- Specified by:
compare
in interface Comparator
- Overrides:
compare
in class AbstractComparator
- Following copied from interface:
jdsl.core.api.Comparator
- Parameters:
a
- First Object to compareb
- Second Object to compare- Returns:
- A negative value if a is less than b, 0 if they are equal,
or a positive value if a is greater than b.