public class MultidimensionalCounter extends Object implements Iterable<Integer>
Modifier and Type | Class and Description |
---|---|
class |
MultidimensionalCounter.Iterator
Perform iteration over the multidimensional counter.
|
Constructor and Description |
---|
MultidimensionalCounter(int... size)
Create a counter.
|
Modifier and Type | Method and Description |
---|---|
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() |
public MultidimensionalCounter(int... size) throws NotStrictlyPositiveException
size
- Counter sizes (number of slots in each dimension).NotStrictlyPositiveException
- if one of the sizes is
negative or zero.public MultidimensionalCounter.Iterator iterator()
public int getDimension()
public int[] getCounts(int index) throws OutOfRangeException
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, DimensionMismatchException
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()
Copyright © 2003–2014 The Apache Software Foundation. All rights reserved.