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 stream. |
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)
Generates a stream of all possible permutations for 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)
items.
This method is an overload of of(Collection) that accepts an array instead of
a collection.
T - Type of the elementsitems - Array of items to create permutations foritemsNullPointerException - if items is null@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.
This method generates a stream that contains all possible arrangements of the elements
within the provided items list.
Note that the number of permutations increases very rapidly as the length of
the provided items list increases, so use with caution with large lists.
T - Type of the elementsitems - List of items to create permutations foritems listNullPointerException - if the provided items list is nullIllegalArgumentException - if the provided permutation number is negativepublic static <T> Stream<List<T>> of(@NotNull @NotNull Stream<T> items)
items stream.
This method generates a stream that contains all possible arrangements of the elements
within the provided items stream.
Note that the number of permutations increases very rapidly as the length of
the provided items stream increases, so use with caution with large streams.
It is unspecified if the method lazily consumes the provided stream before providing the result or not.
T - Type of the elementsitems - Stream of items to create permutations for; must not be nullitems streamNullPointerException - if the provided items stream is nullCopyright © 2024. All rights reserved.