iitb.con.util
Class Unbound2DIntArray

java.lang.Object
  extended by iitb.con.util.Unbound2DIntArray

public class Unbound2DIntArray
extends java.lang.Object

Unbound 2d integer array with two columns


Field Summary
 int length
          The number of values currently present in the array.
 
Constructor Summary
Unbound2DIntArray(int size, int cols)
          Constructor with full specification.
 
Method Summary
 int add(int... values)
          Add a value to the array, appending it after the current values.
 void clear()
          Set the array to the empty state.
 void dump()
          Prints the contents of the array
 void ensureCapacity(int min)
          Ensure that the array has the capacity for at least the specified number of values.
 int[] get(int index)
          Retrieve the value present at an index position in the array.
 void set(int index, int... values)
          Set the value at an index position in the array.
 int size()
          Get the number of values currently present in the array.
 int[][] toArray()
          Constructs and returns a simple array containing the same data as held in this growable array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

length

public int length
The number of values currently present in the array.

Constructor Detail

Unbound2DIntArray

public Unbound2DIntArray(int size,
                         int cols)
Constructor with full specification.

Parameters:
size - number of int values initially allowed in array
cols - number of columns
Method Detail

add

public final int add(int... values)
Add a value to the array, appending it after the current values.

Parameters:
values - value to be added
Returns:
index number of added element

clear

public final void clear()
Set the array to the empty state.


dump

public void dump()
Prints the contents of the array


ensureCapacity

public final void ensureCapacity(int min)
Ensure that the array has the capacity for at least the specified number of values.

Parameters:
min - minimum capacity to be guaranteed

get

public final int[] get(int index)
Retrieve the value present at an index position in the array.

Parameters:
index - index position for value to be retrieved
Returns:
value from position in the array

set

public final void set(int index,
                      int... values)
Set the value at an index position in the array.

Parameters:
index - index position to be set
values - value to be set

size

public final int size()
Get the number of values currently present in the array.

Returns:
count of values present

toArray

public int[][] toArray()
Constructs and returns a simple array containing the same data as held in this growable array.

Returns:
array containing a copy of the data