Opus5
Class MultiDimensionalArray

java.lang.Object
  |
  +--Opus5.MultiDimensionalArray

public class MultiDimensionalArray
extends java.lang.Object

A multi-dimensional array of Objects implemented using a one-dimensional array.

Version:
$Id: MultiDimensionalArray.java,v 3.1 1998/07/28 01:32:17 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Constructor Summary
MultiDimensionalArray(int[] arg)
          Constructs a MultiDimensionalArray with the specified dimensions.
 
Method Summary
 java.lang.Object get(int[] indices)
          Returns the object in this multi-dimensional array at the position specified by the specified indices.
protected  int getOffset(int[] indices)
          Maps a set of indices for the multi-dimensional array into the corresponding position in the one-dimensional array.
 void put(int[] indices, java.lang.Object object)
          Stores the specified object in this multi-dimensional array at the position specified by the specified indices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiDimensionalArray

public MultiDimensionalArray(int[] arg)
Constructs a MultiDimensionalArray with the specified dimensions.
Parameters:
arg - The dimensions of the desired array.
Method Detail

getOffset

protected int getOffset(int[] indices)
Maps a set of indices for the multi-dimensional array into the corresponding position in the one-dimensional array.
Parameters:
indices - The set of indices.
Returns:
A position in the one-dimensional array.
Throws:
java.lang.IllegalArgumentException - If the array of indices has the wrong length.
java.lang.IndexOutOfBoundsException - If the any one of the indices is out of bounds.

get

public java.lang.Object get(int[] indices)
Returns the object in this multi-dimensional array at the position specified by the specified indices.
Parameters:
indices - The set of indices.
Returns:
The object at the specified position.
Throws:
java.lang.IllegalArgumentException - If the array of indices has the wrong length.
java.lang.IndexOutOfBoundsException - If the any one of the indices is out of bounds.

put

public void put(int[] indices,
                java.lang.Object object)
Stores the specified object in this multi-dimensional array at the position specified by the specified indices.
Parameters:
indices - The set of indices.
Throws:
java.lang.IllegalArgumentException - If the array of indices has the wrong length.
java.lang.IndexOutOfBoundsException - If the any one of the indices is out of bounds.