combinatorics
Class VariatorWithRepetition<T>
java.lang.Object
combinatorics.CombinatoricOperator<T>
combinatorics.VariatorWithRepetition<T>
- Type Parameters:
T
- The type of the elements of which variations are to be
returned.
- All Implemented Interfaces:
- java.lang.Iterable<T[]>, java.util.Iterator<T[]>
public final class VariatorWithRepetition<T>
- extends CombinatoricOperator<T>
A class that sequentially returns all variations with repetition of a certain
number out of an array of given elements.
- Author:
- Hendrik Maryns
Constructor Summary |
VariatorWithRepetition(T[] elements,
int r)
Initialise a new variator, with given elements and size of the arrays
to be returned. |
Method Summary |
protected void |
computeNext()
Compute the next array of indices. |
protected void |
initialiseIndices()
Initialise the array of indices. |
protected double |
initialiseTotal(int n,
int r)
Compute the total number of elements to return. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
VariatorWithRepetition
public VariatorWithRepetition(T[] elements,
int r)
- Initialise a new variator, with given elements and size of the arrays
to be returned.
- Parameters:
elements
- The elements of which variations have to be computed.r
- The size of the variations to compute.
initialiseIndices
protected void initialiseIndices()
- Initialise the array of indices. For variations with repetition, it
needs to be initialised with all 0s.
- Overrides:
initialiseIndices
in class CombinatoricOperator<T>
initialiseTotal
protected double initialiseTotal(int n,
int r)
- Compute the total number of elements to return.
- Specified by:
initialiseTotal
in class CombinatoricOperator<T>
- Parameters:
n
- The number of elements the operator works on.r
- The size of the arrays to return.
- Returns:
- The total number of elements is always bigger than 0.
| result >= 0
- See Also:
CombinatoricOperator#initialiseTotal()
computeNext
protected void computeNext()
- Compute the next array of indices.
- Specified by:
computeNext
in class CombinatoricOperator<T>
- See Also:
CombinatoricOperator.computeNext()
Copyright © 2008 This is an undergraduate research project at the University of Kent Computing Laboratory. All Rights Reserved.