|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcombinatorics.CartesianProduct<T>
public class CartesianProduct<T>
A class that sequentially returns the cartesian product of sets, represented as a two-dimensional array. TODO: incorporate this into my CombinatoricOperator frame.
Field Summary | |
---|---|
protected T[][] |
elements
The elements the operator works upon. |
protected int[] |
indices
An integer array backing up the original one to keep track of the indices. |
Constructor Summary | |
---|---|
CartesianProduct(T[][] elements)
Initialise a new operator, with given elements and size of the arrays to be returned. |
Method Summary | |
---|---|
protected void |
computeNext()
Compute the next array of indices. |
int |
getNumLeft()
Return number of variations not yet generated. |
int |
getTotal()
Return the total number of variations. |
boolean |
hasNext()
Returns true if the iteration has more elements. |
protected void |
initialiseIndices()
Initialise the array of indices. |
protected int |
initialiseTotal()
Compute the total number of elements to return. |
java.util.Iterator<T[]> |
iterator()
A combinatoric operator is itself an iterator. |
T[] |
next()
Compute the next combination. |
void |
remove()
Not supported. |
void |
reset()
Reset the iteration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected T[][] elements
protected int[] indices
Constructor Detail |
---|
public CartesianProduct(T[][] elements)
elements
- The elements on which this combinatoric operator has to act.Method Detail |
---|
protected void initialiseIndices()
protected int initialiseTotal()
n
- The number of elements the operator works on.r
- The size of the arrays to return.
public void reset()
public int getNumLeft()
public int getTotal()
public boolean hasNext()
hasNext
in interface java.util.Iterator<T[]>
Iterator.hasNext()
public T[] next()
next
in interface java.util.Iterator<T[]>
Iterator.next()
protected void computeNext()
public void remove()
remove
in interface java.util.Iterator<T[]>
Iterator.remove()
public java.util.Iterator<T[]> iterator()
iterator
in interface java.lang.Iterable<T[]>
Iterable.iterator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |