|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math3.util.MultidimensionalCounter
public class MultidimensionalCounter
Converter between unidimensional storage structure and multidimensional conceptual structure. This utility will convert from indices in a multidimensional structure to the corresponding index in a one-dimensional array. For example, assuming that the ranges (in 3 dimensions) of indices are 2, 4 and 3, the following correspondences, between 3-tuples indices and unidimensional indices, will hold:
Nested Class Summary | |
---|---|
class |
MultidimensionalCounter.Iterator
Perform iteration over the multidimensional counter. |
Field Summary | |
---|---|
private int |
dimension
Number of dimensions. |
private int |
last
Index of last dimension. |
private int[] |
size
Counter sizes. |
private int |
totalSize
Total number of (one-dimensional) slots. |
private int[] |
uniCounterOffset
Offset for each dimension. |
Constructor Summary | |
---|---|
MultidimensionalCounter(int... size)
Create a counter. |
Method Summary | |
---|---|
int |
getCount(int... c)
Convert to unidimensional counter. |
int[] |
getCounts(int index)
Convert to multidimensional counter. |
int |
getDimension()
Get the number of dimensions of the multidimensional counter. |
int |
getSize()
Get the total number of elements. |
int[] |
getSizes()
Get the number of multidimensional counter slots in each dimension. |
MultidimensionalCounter.Iterator |
iterator()
Create an iterator over this counter. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final int dimension
private final int[] uniCounterOffset
private final int[] size
private final int totalSize
private final int last
Constructor Detail |
---|
public MultidimensionalCounter(int... size)
size
- Counter sizes (number of slots in each dimension).
NotStrictlyPositiveException
- if one of the sizes is
negative or zero.Method Detail |
---|
public MultidimensionalCounter.Iterator iterator()
iterator
in interface Iterable<Integer>
public int getDimension()
public int[] getCounts(int index)
index
- Index in unidimensional counter.
OutOfRangeException
- if index
is not between
0
and the value returned by getSize()
(excluded).public int getCount(int... c) throws OutOfRangeException
c
- Indices in multidimensional counter.
DimensionMismatchException
- if the size of c
does not match the size of the array given in the constructor.
OutOfRangeException
- if a value of c
is not in
the range of the corresponding dimension, as defined in the
constructor
.public int getSize()
public int[] getSizes()
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |