public static class JMEMath.Secuencias
extends java.lang.Object
Constructor and Description |
---|
Secuencias() |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.List<java.util.List<T>> |
getPermutations(java.util.List<T> items,
int length)
Get all permutations with a specified length
|
static <T> java.util.List<java.util.List<T>> |
getSequences(java.util.List<T> items,
int length)
Get all sequences with a specific length
Sample: * length:2,[1,2] -> [[1,1],[1,2],[2,1],[2,2]] * length:3,[1] -> [[1,1,1]] * length:1,[1,2] -> [[1],[2]] The number of sequences is equal to variations with repetition of m elements taken by n (m^n) |
static <T> java.util.List<java.util.List<T>> |
getSequencesNoDuplicates(java.util.List<T> items,
int length)
Same as getSequences, but 'items' can have duplicates, although
duplicate sequences will be erased.
|
static <T> java.util.List<java.util.List<T>> |
getSortedSequences(java.util.List<T> items,
int length)
getSortedSequences with default comparator (natural ordering)
|
static <T> java.util.List<java.util.List<T>> |
getSortedSequences(java.util.List<T> items,
int length,
java.util.Comparator<T> comp)
Get all ordered sequences with a specified length.
|
static <T> java.util.HashSet<java.util.List<T>> |
getSubsets(java.util.List<T> items)
Generate all subsets in a list with non-duplicates elements, or all
non-duplicate sequences with a list of duplicate elements.
|
static <T> java.util.List<java.util.List<T>> |
getSubsetsWithDuplicates(java.util.List<T> items)
Obtiene todos los subconjuntos incluyendo elementos y conjuntos duplicados
|
public static <T> java.util.List<java.util.List<T>> getSubsetsWithDuplicates(java.util.List<T> items) throws JMEInterruptedException, java.lang.OutOfMemoryError
items
- conjunto de elementosJMEInterruptedException
- si el hilo se interrumpejava.lang.OutOfMemoryError
- java heap spacepublic static <T> java.util.HashSet<java.util.List<T>> getSubsets(java.util.List<T> items) throws JMEInterruptedException
[1,2] -> [[1,2],[],[1],[2]], [1,1] -> [[],[1],[1,1]]
T
- elementos del conjuntoitems
- a list with the items to generate subsetsJMEInterruptedException
- si el hilo se interrumpepublic static <T> java.util.List<java.util.List<T>> getPermutations(java.util.List<T> items, int length) throws JMEInterruptedException
items
- a list with items to permutatelength
- size of the permutationsJMEInterruptedException
- si el hilo se interrumpepublic static <T> java.util.List<java.util.List<T>> getSortedSequences(java.util.List<T> items, int length, java.util.Comparator<T> comp) throws JMEInterruptedException
length: 2, [1,2] -> [[1,1],[2,2],[1,2]]
items
- a list with the items to create sequenceslength
- size of the sequencescomp
- comparator for items (null for natural ordering)JMEInterruptedException
- si el hilo se interrumpepublic static <T> java.util.List<java.util.List<T>> getSequencesNoDuplicates(java.util.List<T> items, int length) throws JMEInterruptedException
length:2, [1,2,1] -> [[2,1],[1,1],[2,2],[1,2]]
JMEInterruptedException
public static <T> java.util.List<java.util.List<T>> getSortedSequences(java.util.List<T> items, int length)
public static <T> java.util.List<java.util.List<T>> getSequences(java.util.List<T> items, int length) throws JMEInterruptedException
* length:2,[1,2] -> [[1,1],[1,2],[2,1],[2,2]]
* length:3,[1] -> [[1,1,1]]
* length:1,[1,2] -> [[1],[2]]
items
- a list with the items in the sequence with no duplicateslength
- size of the sequencesJMEInterruptedException
- si el hilo se interrumpe