org.ourgrid.common.util
Class BidimensionalArray<E>

java.lang.Object
  extended by org.ourgrid.common.util.BidimensionalArray<E>

public class BidimensionalArray<E>
extends java.lang.Object

Class to provide a Bidimensional Array


Constructor Summary
BidimensionalArray(int initialArrayLength)
           
 
Method Summary
 E get(int x_index, int y_index)
          Gets the element at the determinated position.
 boolean insert(int x_index, int y_index, E element)
          Inserts a new element at the determinated coordenate.
 void insertAtColumn(int column, E element)
           
 void insertAtRow(int row, E element)
           
 E remove(int x_index, int y_index)
           
 void replace(int x_index, int y_index, E element)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BidimensionalArray

public BidimensionalArray(int initialArrayLength)
Method Detail

insert

public boolean insert(int x_index,
                      int y_index,
                      E element)
Inserts a new element at the determinated coordenate. If the coordenate already exists in this BidimensionalArray, the old element is replaced by the specified element.

Parameters:
x_index - Represents the "x" position, as a cartesian plane.
y_index - Represents the "y" position, as a cartesian plane.
element - The element to be added.

insertAtRow

public void insertAtRow(int row,
                        E element)

insertAtColumn

public void insertAtColumn(int column,
                           E element)

get

public E get(int x_index,
             int y_index)
Gets the element at the determinated position. Returns null if the position is not assigned.

Parameters:
x_index - Represents the "x" position, as a cartesian plane.
y_index - Represents the "y" position, as a cartesian plane.

remove

public E remove(int x_index,
                int y_index)

replace

public void replace(int x_index,
                    int y_index,
                    E element)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object