gnu.lists
Class GeneralArray

java.lang.Object
  extended by gnu.lists.AbstractSequence
      extended by gnu.lists.GeneralArray
All Implemented Interfaces:
Array
Direct Known Subclasses:
GeneralArray1

public class GeneralArray
extends AbstractSequence
implements Array

A class to handle general multi-dimensional arrays. This class is unfinished. If the number of dimensions (the "rank") is one, should use a class that implements Sequence. GeneralArray uses a SimpleVector 'base' to store the actual data, and provides general linear mapping from the array indexes to an element index in the 'base' SimpleVector. Thus such uperations as transposing an array can be implement as just creating a simple re-mapping of the indexes.


Constructor Summary
GeneralArray()
           
GeneralArray(int[] dimensions)
           
 
Method Summary
 int createPos(int index, boolean isAfter)
          Generate a position at a given index.
 java.lang.Object get(int index)
          See java.util.List.
 java.lang.Object get(int[] indexes)
           
 int getEffectiveIndex(int[] indexes)
          Calculate corresponding index in base array.
 int getLowBound(int dim)
          Get the least dimension along the specified dimension.
 java.lang.Object getRowMajor(int index)
           
 int getSize(int dim)
          Get length along specified dimension.
static Array makeSimple(int[] lowBounds, int[] dimensions, SimpleVector base)
           
 int rank()
          Get the rank (number of dimensions) of this array.
 java.lang.Object set(int[] indexes, java.lang.Object value)
           
 int size()
          See java.util.Collection.
 java.lang.String toString()
           
static void toString(Array array, java.lang.StringBuffer sbuf)
           
 Array transpose(int[] lowBounds, int[] dimensions, int offset0, int[] factors)
           
 
Methods inherited from class gnu.lists.AbstractSequence
add, add, addAll, addAll, addPos, clear, compare, compare, compare, consume, consumeNext, consumePosRange, contains, containsAll, copyPos, createRelativePos, elements, endPos, equals, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, getAttribute, getAttributeLength, getContainingSequenceSize, getIndexDifference, getIterator, getIterator, getIteratorAtPos, getNextKind, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, gotoAttributesStart, gotoChildrenStart, gotoParent, hashCode, hasNext, hasPrevious, indexOf, isAfterPos, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextIndex, nextMatching, nextPos, parentPos, previousPos, releasePos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, setPosNext, setPosPrevious, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, unsupported, unsupportedException
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gnu.lists.Array
isEmpty
 

Constructor Detail

GeneralArray

public GeneralArray()

GeneralArray

public GeneralArray(int[] dimensions)
Method Detail

makeSimple

public static Array makeSimple(int[] lowBounds,
                               int[] dimensions,
                               SimpleVector base)

rank

public int rank()
Description copied from interface: Array
Get the rank (number of dimensions) of this array. The rank of a scalar is 0, of a Sequence is 1, of a matrix is 2, etc.

Specified by:
rank in interface Array
Overrides:
rank in class AbstractSequence

getEffectiveIndex

public int getEffectiveIndex(int[] indexes)
Calculate corresponding index in base array.

Specified by:
getEffectiveIndex in interface Array
Overrides:
getEffectiveIndex in class AbstractSequence

get

public java.lang.Object get(int index)
Description copied from class: AbstractSequence
See java.util.List.

Specified by:
get in class AbstractSequence

createPos

public int createPos(int index,
                     boolean isAfter)
Description copied from class: AbstractSequence
Generate a position at a given index. The result is a position cookie that must be free'd with releasePos.

Specified by:
createPos in class AbstractSequence
Parameters:
index - offset from beginning of desired position
isAfter - should the position have the isAfter property

getRowMajor

public java.lang.Object getRowMajor(int index)
Specified by:
getRowMajor in interface Array

get

public java.lang.Object get(int[] indexes)
Specified by:
get in interface Array
Overrides:
get in class AbstractSequence

set

public java.lang.Object set(int[] indexes,
                            java.lang.Object value)
Specified by:
set in interface Array
Overrides:
set in class AbstractSequence

size

public int size()
See java.util.Collection.

Specified by:
size in class AbstractSequence

getLowBound

public int getLowBound(int dim)
Description copied from interface: Array
Get the least dimension along the specified dimension.

Specified by:
getLowBound in interface Array
Overrides:
getLowBound in class AbstractSequence

getSize

public int getSize(int dim)
Description copied from interface: Array
Get length along specified dimension.

Specified by:
getSize in interface Array
Overrides:
getSize in class AbstractSequence

transpose

public Array transpose(int[] lowBounds,
                       int[] dimensions,
                       int offset0,
                       int[] factors)
Specified by:
transpose in interface Array

toString

public static void toString(Array array,
                            java.lang.StringBuffer sbuf)

toString

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