xxl.util
Class Tuple
java.lang.Object
|
+--xxl.util.Tuple
- public class Tuple
- extends java.lang.Object
This class implements a Tuple of objects. A tuple is compared and hashed in terms of its objects.
|
Field Summary |
protected java.lang.Object[] |
objects
|
|
Constructor Summary |
Tuple(java.lang.Object[] objects)
Creates an tuple using the given array. |
|
Method Summary |
boolean |
equals(java.lang.Object o)
Compares two tuples in terms of their objects. |
java.lang.Object |
get(int index)
Gets the object stored at the given index. |
int |
hashCode()
Computes a hash code for this tuple based on the objects stored in it. |
int |
length()
Returns the length of the underlying array. |
java.lang.Object |
set(int index,
java.lang.Object object)
Updates this tuple at the given index with the given object. |
| Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
notify,
notifyAll,
toString,
wait,
wait,
wait |
objects
protected java.lang.Object[] objects
Tuple
public Tuple(java.lang.Object[] objects)
- Creates an tuple using the given array.
- Parameters:
objects - The array that backs the tuple.
length
public int length()
- Returns the length of the underlying array.
- Returns:
- The length of the underlying array.
equals
public boolean equals(java.lang.Object o)
- Compares two tuples in terms of their objects.
- Parameters:
The - tuple to be compared with.- Overrides:
- equals in class java.lang.Object
hashCode
public int hashCode()
- Computes a hash code for this tuple based on the objects stored in it.
Starting with 0, the hashCodes of the objects are superimposed with xor (^).
The hashCode of null is 0 by definition.
- Overrides:
- hashCode in class java.lang.Object
set
public java.lang.Object set(int index,
java.lang.Object object)
throws java.lang.IndexOutOfBoundsException
- Updates this tuple at the given index with the given object.
- Parameters:
index - Updates this tuple at index.object - Updates this tuple at the given index with object.- Throws:
- java.lang.IndexOutOfBoundsException - Throw an IndexOutOfBoundsException if the index is negative or greater than or equal to length().
get
public java.lang.Object get(int index)
throws java.lang.IndexOutOfBoundsException
- Gets the object stored at the given index.
- Parameters:
index - Gets the object stored at the given index.- Throws:
- java.lang.IndexOutOfBoundsException - Throw an IndexOutOfBoundsException if the index is negative or greater than or equal to length().