gnu.lists

Class GeneralArray

Implemented Interfaces:
Array
Known Direct 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.
Object
get(int index)
See java.util.List.
Object
get(int[] indexes)
int
getEffectiveIndex(int[] indexes)
int
getLowBound(int dim)
Object
getRowMajor(int index)
int
getSize(int dim)
static Array
makeSimple(int[] lowBounds, int[] dimensions, SimpleVector base)
int
rank()
Object
set(int[] indexes, Object value)
int
size()
See java.util.Collection.
String
toString()
static void
toString(Array array, StringBuffer sbuf)
Array
transpose(int[] lowBounds, int[] dimensions, int offset0, int[] factors)

Methods inherited from class gnu.lists.AbstractSequence

add, add, addAll, addAll, addPos, append, baseUriOfPos, clear, compare, compare, compare, consume, consumeNext, consumePosRange, contains, containsAll, copyPos, createPos, createRelativePos, elements, endPos, equals, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, fromEndIndex, get, get, getAttribute, getAttributeLength, getContainingSequenceSize, getEffectiveIndex, getIndexDifference, getIterator, getIterator, getIteratorAtPos, getLowBound, getNextKind, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hasNext, hasPrevious, hashCode, indexOf, isAfterPos, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextIndex, nextMatching, nextPos, parentPos, previousPos, rank, releasePos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, set, setPosNext, setPosPrevious, size, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, toString, unsupported

Constructor Details

GeneralArray

public GeneralArray()

GeneralArray

public GeneralArray(int[] dimensions)

Method Details

createPos

public int createPos(int index,
                     boolean isAfter)
Generate a position at a given index. The result is a position cookie that must be free'd with releasePos.
Overrides:
createPos in interface AbstractSequence
Parameters:
index - offset from beginning of desired position
isAfter - should the position have the isAfter property

get

public Object get(int index)
See java.util.List.
Overrides:
get in interface AbstractSequence

get

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

getEffectiveIndex

public int getEffectiveIndex(int[] indexes)
Specified by:
getEffectiveIndex in interface Array
Overrides:
getEffectiveIndex in interface AbstractSequence

getLowBound

public int getLowBound(int dim)
Specified by:
getLowBound in interface Array
Overrides:
getLowBound in interface AbstractSequence

getRowMajor

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

getSize

public int getSize(int dim)
Specified by:
getSize in interface Array
Overrides:
getSize in interface AbstractSequence

makeSimple

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

rank

public int rank()
Specified by:
rank in interface Array
Overrides:
rank in interface AbstractSequence

set

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

size

public int size()
See java.util.Collection.
Overrides:
size in interface AbstractSequence

toString

public String toString()
Overrides:
toString in interface AbstractSequence

toString

public static void toString(Array array,
                            StringBuffer sbuf)

transpose

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