org.ddogleg.combinatorics
Class Permute<T>
- java.lang.Object
-
- org.ddogleg.combinatorics.Permute<T>
-
- Type Parameters:
T-
public class Permute<T> extends java.lang.ObjectExhaustively 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
-
-
Constructor Summary
Constructors Constructor and Description Permute()Permute(java.util.List<T> list)Permute the elements in the list provided
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description Tget(int i)Returns element 'i' in the current permutationjava.util.List<T>getPermutation(java.util.List<T> storage)Returns a list containing the current permutation.intgetTotalPermutations()Returns the total number of permutationsstatic voidmain(java.lang.String[] args)booleannext()This will permute the list oncebooleanprevious()This will undo a permutation.intsize()Returns the size of the list being premuted
-
-
-
Constructor Detail
-
Permute
public Permute(java.util.List<T> list)
Permute the elements in the list provided
-
Permute
public Permute()
-
-
Method Detail
-
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
public T get(int i)
Returns element 'i' in the current permutation- Parameters:
i- index- Returns:
- element in permuted list
-
getPermutation
public java.util.List<T> getPermutation(java.util.List<T> storage)
Returns a list containing the current permutation.- Parameters:
storage- Optional storage. If null a new list will be declared.- Returns:
- Current permutation
-
main
public static void main(java.lang.String[] args)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG