net.sourceforge.cilib.container
Class MultiDimensionalArray<E>

java.lang.Object
  extended by net.sourceforge.cilib.container.MultiDimensionalArray<E>
All Implemented Interfaces:
Array

public class MultiDimensionalArray<E>
extends Object
implements Array

This class fills the need to create a arbitraty multi-dimensional array structure.

Author:
gpampara

Constructor Summary
MultiDimensionalArray()
           
MultiDimensionalArray(int... dimensions)
           
 
Method Summary
 Array get(int index)
          Get the element at the provided index.
 E getElement(int... indicies)
          Get the element located at the provided indicies.
<T> void
set(T array, int index)
          Set the element at index.
 void setElement(E element, int... indicies)
          Set the element at the provided index.
 int size()
          Obtain the current size of the array structure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiDimensionalArray

public MultiDimensionalArray()

MultiDimensionalArray

public MultiDimensionalArray(int... dimensions)
Method Detail

size

public int size()
Description copied from interface: Array
Obtain the current size of the array structure.

Specified by:
size in interface Array
Returns:
The array length.

get

public Array get(int index)
Description copied from interface: Array
Get the element at the provided index.

Specified by:
get in interface Array
Parameters:
index - The index of the desired element.
Returns:
The element at index, if available.

set

public <T> void set(T array,
                    int index)
Description copied from interface: Array
Set the element at index.

Specified by:
set in interface Array
Type Parameters:
T - The generic type.
Parameters:
array - The object to place within the array.
index - The index to set the object at.

setElement

public void setElement(E element,
                       int... indicies)
Set the element at the provided index. The index is a list defining the traversal path into the multi-dimensional array.

Parameters:
element - The element to set at the given index position.
indicies - The indicies to follow.

getElement

public E getElement(int... indicies)
Get the element located at the provided indicies.

Parameters:
indicies - The list of indecies to follow to obtain the desired element.
Returns:
The target element at the provided index.
Throws:
IndexOutOfBoundsException - if an index is larger that a sub-array.


Copyright © 2009 CIRG. All Rights Reserved.