net.sourceforge.domian.test.combinatorics
Class Sequence

java.lang.Object
  extended by net.sourceforge.domian.test.combinatorics.Sequence
All Implemented Interfaces:
java.util.Iterator<int[]>
Direct Known Subclasses:
Combination, Permutation

public class Sequence
extends java.lang.Object
implements java.util.Iterator<int[]>

This class generates a list with number sequences according to a given length, n, and number of elements, m. The list of number sequences are zero-based.

The number sequences of n elements chosen from a list of m elements, are the possible number arrangements where the ordering of elements is taken into consideration.

no: "Urnemodell - Ordnet utvalg med tilbakelegging"

Med "ordnet" menes det at rekkefølgen som elementene er ordnet etter tas hensyn til.
Med "med tilbakelegging" menes det at elementer kan forekomme mer enn én gang.

Author:
Eirik Torske

Field Summary
protected  int m
           
protected  int n
           
private  long S
           
protected  int[] sequence
           
protected  long sequenceNumber
           
 
Constructor Summary
Sequence(int n)
          The number of elements to use is set equal to the length of the number sequences.
Sequence(int m, int n)
           
 
Method Summary
protected  void calculateTotalNumberOfSequences()
           
 boolean hasNext()
           
 int[] next()
           
 void remove()
           
 void reset()
           
private  void revolveSequence()
           
protected  boolean sequenceConstraintOk()
          Number sequence constraint: None.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m

protected final int m

n

protected final int n

S

private long S

sequenceNumber

protected long sequenceNumber

sequence

protected int[] sequence
Constructor Detail

Sequence

public Sequence(int n)
The number of elements to use is set equal to the length of the number sequences.

Parameters:
n - the length of the number sequences.

Sequence

public Sequence(int m,
                int n)
Parameters:
m - the number of possible elements to use within each number sequence.
n - the length of the number sequences.
Method Detail

revolveSequence

private void revolveSequence()

calculateTotalNumberOfSequences

protected void calculateTotalNumberOfSequences()

sequenceConstraintOk

protected boolean sequenceConstraintOk()
Number sequence constraint: None.


hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<int[]>

next

public int[] next()
Specified by:
next in interface java.util.Iterator<int[]>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<int[]>

reset

public void reset()


Copyright © 2008-2010. All Rights Reserved.