public final class Permutation extends Object
| Modifier and Type | Method and Description |
|---|---|
static long |
factorial(int n)
Returns the factorial (n!) for the given
n value. |
static <T> Stream<List<T>> |
of(Collection<T> items)
Creates and returns a Stream of all permutations of the provided
items list. |
static <T> Stream<List<T>> |
of(T... items)
Creates and returns a Stream of all permutations of the provided
items array. |
static <T> List<T> |
permutation(long no,
List<T> items)
Returns the given
no (of n!) permutation variant of the
given items. |
public static long factorial(int n)
n value.n - parametern valuepublic static <T> List<T> permutation(long no, List<T> items)
no (of n!) permutation variant of the
given items.
Note that the number of permutations increases very rapidly as the length of
the provided items array increases.
T - type of the elementsno - index to get permutations foritems - to create permutations forno (of n!) permutation variant of the
given items@SafeVarargs public static <T> Stream<List<T>> of(T... items)
items array.
Note that the number of permutations increases very rapidly as the length of
the provided items array increases.
T - type of the elementsitems - to create permutations foritems arrayNullPointerException - is the provided items array is null.public static <T> Stream<List<T>> of(Collection<T> items)
items list.
Note that the number of permutations increases very rapidly as the length of
the provided items list increases.
T - type of the elementsitems - to create permutations foritems listNullPointerException - is the provided items list is null.Copyright © 2022. All rights reserved.