|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.ma2.Index
public class Index
Indexes for Multidimensional arrays. This refers to a particular element of an array. This is a generalization of index as int []. Its main function is to do the index arithmetic to translate an n-dim index into a 1-dim index. The user obtains this by calling getIndex() on a Array. The set() and seti() routines are convenience routines for 1-7 dim arrays.
Array| Field Summary | |
|---|---|
protected int[] |
current
current element's index, used only for the general case |
protected boolean |
fastIterator
Iterator implementation |
protected java.lang.String[] |
name
index names (optional) |
protected int |
offset
element = offset + stride[0]*current[0] + ... |
protected int |
rank
array rank |
protected int[] |
shape
array shape |
protected long |
size
total number of elements |
protected int[] |
stride
array stride |
| Constructor Summary | |
|---|---|
protected |
Index(int rank)
General case Index - use when you want to manipulate current elements yourself |
protected |
Index(int[] _shape)
constructor for subclasses only. |
protected |
Index(int[] _shape,
int[] _stride)
constructor for subclasses only. |
| Method Summary | |
|---|---|
java.lang.Object |
clone()
|
static long |
computeSize(int[] shape)
Compute total number of elements in the array. |
int |
currentElement()
Get the current element's index into the 1D backing array. |
static Index |
factory(int[] shape)
Generate a subclass of Index optimized for this array's rank |
int[] |
getCurrentCounter()
|
java.lang.String |
getIndexName(int dim)
Get the name of one of the indices. |
int |
getRank()
Get the number of dimensions in the array. |
int[] |
getShape()
Get the shape: length of array in each dimension. |
long |
getSize()
Get the total number of elements in the array. |
protected int |
incr()
Increment the current element by 1. |
protected void |
precalc()
subclass specialization/optimization calculations |
Index |
set(int v0)
set current element at dimension 0 to v0 |
Index |
set(int[] index)
Set the current element's index. |
Index |
set(int v0,
int v1)
set current element at dimension 0,1 to v0,v1 |
Index |
set(int v0,
int v1,
int v2)
set current element at dimension 0,1,2 to v0,v1,v2 |
Index |
set(int v0,
int v1,
int v2,
int v3)
set current element at dimension 0,1,2,3 to v0,v1,v2,v3 |
Index |
set(int v0,
int v1,
int v2,
int v3,
int v4)
set current element at dimension 0,1,2,3,4 to v0,v1,v2,v3,v4 |
Index |
set(int v0,
int v1,
int v2,
int v3,
int v4,
int v5)
set current element at dimension 0,1,2,3,4,5 to v0,v1,v2,v3,v4,v5 |
Index |
set(int v0,
int v1,
int v2,
int v3,
int v4,
int v5,
int v6)
set current element at dimension 0,1,2,3,4,5,6 to v0,v1,v2,v3,v4,v5,v6 |
Index |
set0(int v)
set current element at dimension 0 to v |
Index |
set1(int v)
set current element at dimension 1 to v |
Index |
set2(int v)
set current element at dimension 2 to v |
Index |
set3(int v)
set current element at dimension 3 to v |
Index |
set4(int v)
set current element at dimension 4 to v |
Index |
set5(int v)
set current element at dimension 5 to v |
Index |
set6(int v)
set current element at dimension 6 to v |
void |
setDim(int dim,
int value)
set current element at dimension dim to v |
void |
setIndexName(int dim,
java.lang.String indexName)
Set the name of one of the indices. |
java.lang.String |
toString()
|
java.lang.String |
toStringDebug()
String representation |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int[] shape
protected int rank
protected long size
protected int[] stride
protected int offset
protected int[] current
protected java.lang.String[] name
protected boolean fastIterator
| Constructor Detail |
|---|
protected Index(int rank)
protected Index(int[] _shape)
protected Index(int[] _shape,
int[] _stride)
| Method Detail |
|---|
protected void precalc()
public int getRank()
public int[] getShape()
public long getSize()
public int currentElement()
protected int incr()
public Index set(int[] index)
java.lang.ArrayIndexOutOfBoundsException - if index.length != rank.
public void setDim(int dim,
int value)
public Index set0(int v)
public Index set1(int v)
public Index set2(int v)
public Index set3(int v)
public Index set4(int v)
public Index set5(int v)
public Index set6(int v)
public Index set(int v0)
public Index set(int v0,
int v1)
public Index set(int v0,
int v1,
int v2)
public Index set(int v0,
int v1,
int v2,
int v3)
public Index set(int v0,
int v1,
int v2,
int v3,
int v4)
public Index set(int v0,
int v1,
int v2,
int v3,
int v4,
int v5)
public Index set(int v0,
int v1,
int v2,
int v3,
int v4,
int v5,
int v6)
public java.lang.String toStringDebug()
public java.lang.String toString()
toString in class java.lang.Objectpublic int[] getCurrentCounter()
public java.lang.Object clone()
clone in class java.lang.Object
public void setIndexName(int dim,
java.lang.String indexName)
dim - which index?indexName - name of indexpublic java.lang.String getIndexName(int dim)
dim - which index?
public static Index factory(int[] shape)
public static long computeSize(int[] shape)
shape - length of array in each dimension.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||