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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public MultidimensionalCounter(int... size) throws MathIllegalArgumentException
size
- Counter sizes (number of slots in each dimension).MathIllegalArgumentException
- if one of the sizes is
negative or zero.public MultidimensionalCounter.Iterator iterator()
public int getDimension()
public int[] getCounts(int index) throws MathIllegalArgumentException
index
- Index in unidimensional counter.MathIllegalArgumentException
- if index
is not between
0
and the value returned by getSize()
(excluded).public int getCount(int... c) throws MathIllegalArgumentException
c
- Indices in multidimensional counter.MathIllegalArgumentException
- if the size of c
does not match the size of the array given in the constructor.MathIllegalArgumentException
- 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 © 2016-2021 CS GROUP. All rights reserved.