Package org.ddogleg.combinatorics
Class Permute<T>
java.lang.Object
org.ddogleg.combinatorics.Permute<T>
- Type Parameters:
T
-
Exhaustively computes all the permutations of a set, without recursion. Designed to be memory and speed efficient.
Example for the set "0123".
0123
0132
0213
0231
0321
0312
1023
1032
1203
1230
1320
1302
2103
2130
2013
2031
2301
2310
3120
3102
3210
3201
3021
3012
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionget
(int i) Returns element 'i' in the current permutationgetPermutation
(@Nullable List<T> storage) Returns a list containing the current permutation.int
Returns the total number of permutationsstatic void
boolean
next()
This will permute the list onceboolean
previous()
This will undo a permutation.int
size()
Returns the size of the list being premuted
-
Field Details
-
list
-
-
Constructor Details
-
Permute
Permute the elements in the list provided
-
-
Method Details
-
getTotalPermutations
public int getTotalPermutations()Returns the total number of permutations -
next
public boolean next()This will permute the list once -
previous
public boolean previous()This will undo a permutation. -
size
public int size()Returns the size of the list being premuted- Returns:
- list size
-
get
Returns element 'i' in the current permutation- Parameters:
i
- index- Returns:
- element in permuted list
-
getPermutation
Returns a list containing the current permutation.- Parameters:
storage
- Optional storage. If null a new list will be declared.- Returns:
- Current permutation
-
main
-