ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.util
Class IntArray

java.lang.Object
  extended by umontreal.iro.lecuyer.util.IntArray
All Implemented Interfaces:
Comparable<IntArray>

public class IntArray
extends Object
implements Comparable<IntArray>

Represents an immutable array of integers. This class is similar to the Integer class, but it wraps an array of integers rather than an integer. Instances of this class can be used as set elements or map keys, because this class implements the hashCode() and equals(Object) methods to compare the contents of the array.


Field Summary
 int length
          Gives the length of the wrapped array.
 
Constructor Summary
IntArray(int[] array)
          Constructs a new array object from the given array of integers.
 
Method Summary
 int compareTo(IntArray o)
           
 boolean equals(Object o)
          If o corresponds to an instance of IntArray, tests the equality of the wrapped arrays using int[]), and returns the result of the test.
 int[] getArray()
          Returns a copy of the wrapped array.
 int getElement(int i)
          Returns the element with index i of the wrapped array.
 int hashCode()
          Returns the result of Arrays.hashCode(int[]) on the wrapped array.
 String toString()
          Returns the result of Arrays.toString(int[]) called on the wrapped array.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

length

public final int length
Gives the length of the wrapped array.

Constructor Detail

IntArray

public IntArray(int[] array)
Constructs a new array object from the given array of integers. A null value is considered as an array with length 0.

Parameters:
array - the array to be wrapped.
Method Detail

getArray

public int[] getArray()
Returns a copy of the wrapped array. Note that modifying the returned array does not affect the array wrapped by this object.

Returns:
a copy of the wrapped array.

getElement

public int getElement(int i)
Returns the element with index i of the wrapped array.

Parameters:
i - the queried index.
Returns:
the value of the element.
Throws:
ArrayIndexOutOfBoundsException - if i is negative or greater than or equal to length.

hashCode

public int hashCode()
Returns the result of Arrays.hashCode(int[]) on the wrapped array.

Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
If o corresponds to an instance of IntArray, tests the equality of the wrapped arrays using int[]), and returns the result of the test. Otherwise, returns false.

Overrides:
equals in class Object

toString

public String toString()
Returns the result of Arrays.toString(int[]) called on the wrapped array.

Overrides:
toString in class Object

compareTo

public int compareTo(IntArray o)
Specified by:
compareTo in interface Comparable<IntArray>

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.