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(@NotNull Collection<T> items)
Creates and returns a Stream of all permutations of the provided
items list. |
static <T> Stream<List<T>> |
of(@NotNull Stream<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,
@NotNull 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, @NotNull @NotNull 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(@NotNull 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 - if the provided items array is null.public static <T> Stream<List<T>> of(@NotNull @NotNull 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 - if the provided items list is null.public static <T> Stream<List<T>> of(@NotNull @NotNull Stream<T> items)
items list.
Note that the number of permutations increases very rapidly as the length of
the provided items list increases.
It is unspecified if the method lazily consume the provided stream before providing the result or not.
T - type of the elementsitems - to create permutations foritems listNullPointerException - if the provided items stream is null.Copyright © 2023. All rights reserved.