|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.bezier.math.combinatorics.CombinatoricsBase
de.bezier.math.combinatorics.Permutation
public class Permutation
Changes in the order
A permutation is a change in the order of a given set of elements. An anagram or a deck of cards being shuffled are examples.
Given the elements [a,b,c] a permutation would produce:
[a,b,c], [a,c,b], [b,a,c], [b,c,a], [c,a,b], [c,b,a].
For 3 elements you will receive 3! (read "!" as factorial) results, that is 3*2*1 = 6
This code is based on: Michael Gillelands code,
which he claims to be an implementation of
Kenneth H. Rosen, Discrete Mathematics and Its Applications, 2nd edition (NY: McGraw-Hill, 1991), pp. 282-284
Constructor Summary | |
---|---|
Permutation(int elements)
|
Method Summary | |
---|---|
boolean |
hasMore()
Are there more results available? Use in conditionals: |
int[] |
next()
Return next result and update internal counter by one |
java.math.BigInteger |
position()
Return copy of internal counter (number of results returned) as BigInteger |
int |
positionAsInt()
Try to return internal counter (number of results returned) as int |
long |
positionAsLong()
Try to return internal counter (number of results returned) as long |
float |
positionInPercent()
How many percent of results returned so far? |
void |
rewind()
As it says, rewinds the internal state to start over. |
Methods inherited from class de.bezier.math.combinatorics.CombinatoricsBase |
---|
nextAndStep, numberOfElements, positionInPercent, total, totalAsInt, totalAsLong |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Permutation(int elements)
elements
- Number of elements in the set to generate permutations for, should be larger than 0Method Detail |
---|
public void rewind()
rewind
in class CombinatoricsBase
public boolean hasMore()
if ( permuti.hasMore() ) { ... }
hasMore
in class CombinatoricsBase
public int[] next()
next
in class CombinatoricsBase
public float positionInPercent()
positionInPercent
in class CombinatoricsBase
public int positionAsInt()
positionAsInt
in class CombinatoricsBase
public long positionAsLong()
positionAsLong
in class CombinatoricsBase
public java.math.BigInteger position()
position
in class CombinatoricsBase
BigInteger
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |