net.sourceforge.domian.test.combinatorics
Class Combination

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

public class Combination
extends Sequence

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

The combinations of n elements chosen from a list of m elements, are the possible arrangements where each element only can appear once and the ordering of elements is not taken into consideration.

no: "Urnemodell - Uordnet utvalg uten tilbakelegging"

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

Author:
Eirik Torske

Field Summary
private  long C
           
 
Fields inherited from class net.sourceforge.domian.test.combinatorics.Sequence
m, n, sequence, sequenceNumber
 
Constructor Summary
Combination(int n)
           
Combination(int m, int n)
           
 
Method Summary
protected  void calculateTotalNumberOfSequences()
           
 boolean hasNext()
           
protected  boolean sequenceConstraintOk()
          Permutation constraint: No numbers in the number sequence can be similar, and numbers must be ascending/ordered.
 
Methods inherited from class net.sourceforge.domian.test.combinatorics.Sequence
next, remove, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C

private long C
Constructor Detail

Combination

public Combination(int n)

Combination

public Combination(int m,
                   int n)
Method Detail

calculateTotalNumberOfSequences

protected void calculateTotalNumberOfSequences()
Overrides:
calculateTotalNumberOfSequences in class Sequence

sequenceConstraintOk

protected boolean sequenceConstraintOk()
Permutation constraint: No numbers in the number sequence can be similar, and numbers must be ascending/ordered.

Overrides:
sequenceConstraintOk in class Sequence

hasNext

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


Copyright © 2008-2010. All Rights Reserved.