Class Collections
java.lang.Object
ushiosan.jvm_utilities.lang.collection.Collections
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull Collection<T>Combine different lists into a single collectionstatic <T> @NotNull Collection<T>Combine different lists into a single collectionCombine different sets into a single collectionstatic <K,V> @Unmodifiable @NotNull Map.Entry<K, V> entryOf(K key, V value) InstantiateMap.Entryto more easily generate data maps.Create an enum set with all enum elements.linkedListOf(@NotNull Collection<T> base) Create a linked list with all given elements.linkedListOf(T @NotNull ... elements) Create a linked list with all given elements.linkedMapOf(Map.Entry<K, V> @NotNull ... entries) Create a linked map with all the given elements.linkedMapOf(Pair<K, V> @NotNull ... pairs) Create a linked map with all the given elements.linkedSetOf(@NotNull Collection<T> base) Create a linked set with all given elements.linkedSetOf(T @NotNull ... elements) Create a linked set with all given elements.static <T> @Unmodifiable List<T>listOf(@NotNull Collection<T> base) Create an immutable list with all given elements.static <T> @Unmodifiable @NotNull List<T>Create an immutable list with all given elements.static <T> @Unmodifiable List<T>Create an immutable list with all given elements.static <K,V> @Unmodifiable @NotNull Map<K, V> mapOf()Create a read-only empty map.static <K,V> @Unmodifiable @NotNull Map<K, V> Create a read-only map with all the given elements.static <K,V> @Unmodifiable @NotNull Map<K, V> Create a read-only map with all the given elements.mutableEntryOf(K key, V value) InstantiateMap.Entryto more easily generate data maps.mutableListOf(@NotNull Collection<T> base) Create a mutable list with all given elements.mutableListOf(@NotNull Iterator<T> iterator) Create a mutable list with all given elements.mutableListOf(T @NotNull ... elements) Create a mutable list with all given elements.Create a mutable map with all the given elements.mutableMapOf(Map.Entry<K, V> @NotNull ... entries) Create a mutable map with all the given elements.mutableMapOf(Pair<K, V> @NotNull ... pairs) Create a mutable map with all the given elements.mutableSetOf(@NotNull Collection<T> base) Create a mutable set with all given elements.mutableSetOf(T @NotNull ... elements) Create a mutable set with all given elements.searchListIndex(@NotNull List<T> base, T search) Returns all indices where the searched element is foundstatic <T> @Unmodifiable @NotNull Set<T>setOf(@NotNull Collection<T> base) Create a set with all given elements.static <T> @Unmodifiable @NotNull Set<T>Create a set with all given elements.stackOf(@NotNull Collection<T> base) Create a stack with all given elements.Create a stack with all given elements.treeSetOf(@Nullable Comparator<T> comparator, @NotNull Collection<T> base) Create a linked set with all given elements.treeSetOf(@Nullable Comparator<T> comparator, T @NotNull ... elements) Create a tree set with all given elements.Create a tree set with all given elements.vectorOf(@NotNull Collection<T> base) Create a vector with all given elements.Create a vector with all given elements.Create a weak-reference map with all the given elements.Create a weak-reference map with all the given elements.
-
Method Details
-
listOf
@SafeVarargs @Contract(pure=true) public static <T> @Unmodifiable List<T> listOf(T @NotNull ... elements) Create an immutable list with all given elements.- Type Parameters:
T- list generic type- Parameters:
elements- the elements to insert- Returns:
- an immutable list with all elements
-
listOf
Create an immutable list with all given elements.- Type Parameters:
T- list generic type- Parameters:
base- the base collection content- Returns:
- an immutable list with all elements
-
listOf
@NotNull public static <T> @Unmodifiable @NotNull List<T> listOf(@NotNull @NotNull Iterator<T> iterator) Create an immutable list with all given elements.- Type Parameters:
T- list generic type- Parameters:
iterator- the base collection content- Returns:
- an immutable list with all elements
-
mutableListOf
@SafeVarargs @Contract("_ -> new") @NotNull public static <T> @NotNull List<T> mutableListOf(T @NotNull ... elements) Create a mutable list with all given elements.- Type Parameters:
T- list generic type- Parameters:
elements- the elements to insert- Returns:
- a mutable list with all elements
-
mutableListOf
Create a mutable list with all given elements.- Type Parameters:
T- list generic type- Parameters:
base- the base collection content- Returns:
- a mutable list with all elements
-
mutableListOf
Create a mutable list with all given elements.- Type Parameters:
T- list generic type- Parameters:
iterator- the base collection content- Returns:
- a mutable list with all elements
-
linkedListOf
Create a linked list with all given elements.- Type Parameters:
T- generic type list- Parameters:
elements- the elements to insert- Returns:
- a linked list with all elements
-
linkedListOf
Create a linked list with all given elements.- Type Parameters:
T- list generic type- Parameters:
base- the base collection content- Returns:
- a linked list with all elements
-
searchListIndex
@NotNull public static <T> @NotNull List<Integer> searchListIndex(@NotNull @NotNull List<T> base, @NotNull T search) Returns all indices where the searched element is found- Type Parameters:
T- generic object type- Parameters:
base- the base listsearch- the object to search- Returns:
- all indices where the searched object is found
-
stackOf
Create a stack with all given elements.- Type Parameters:
T- generic type list- Parameters:
elements- the elements to insert- Returns:
- a stack with all elements
-
stackOf
Create a stack with all given elements.- Type Parameters:
T- list generic type- Parameters:
base- the base collection content- Returns:
- a stack with all elements
-
vectorOf
Create a vector with all given elements.- Type Parameters:
T- generic type list- Parameters:
elements- the elements to insert- Returns:
- a vector with all elements
-
vectorOf
Create a vector with all given elements.- Type Parameters:
T- list generic type- Parameters:
base- the base collection content- Returns:
- a vector with all elements
-
setOf
@SafeVarargs @NotNull public static <T> @Unmodifiable @NotNull Set<T> setOf(T @NotNull ... elements) Create a set with all given elements.- Type Parameters:
T- generic type set- Parameters:
elements- the elements to insert- Returns:
- a set with all elements
-
setOf
@NotNull public static <T> @Unmodifiable @NotNull Set<T> setOf(@NotNull @NotNull Collection<T> base) Create a set with all given elements.- Type Parameters:
T- generic type set- Parameters:
base- the base collection content- Returns:
- a set with all elements
-
mutableSetOf
Create a mutable set with all given elements.- Type Parameters:
T- generic type set- Parameters:
elements- the elements to insert- Returns:
- a set with all elements
-
mutableSetOf
Create a mutable set with all given elements.- Type Parameters:
T- generic type set- Parameters:
base- the base collection content- Returns:
- a set with all elements
-
linkedSetOf
Create a linked set with all given elements.- Type Parameters:
T- generic type set- Parameters:
elements- the elements to insert- Returns:
- a linked set with all elements
-
linkedSetOf
Create a linked set with all given elements.- Type Parameters:
T- generic type set- Parameters:
base- the base collection content- Returns:
- a linked set with all elements
-
treeSetOf
@SafeVarargs @NotNull public static <T> @NotNull Set<T> treeSetOf(@Nullable @Nullable Comparator<T> comparator, T @NotNull ... elements) Create a tree set with all given elements.- Type Parameters:
T- generic type set- Parameters:
comparator- the set comparator (used to sort the elements)elements- the elements to insert- Returns:
- a tree set with all elements
-
treeSetOf
Create a tree set with all given elements.- Type Parameters:
T- generic type set- Parameters:
elements- the elements to insert- Returns:
- a linked set with all elements
-
treeSetOf
@NotNull public static <T> @NotNull Set<T> treeSetOf(@Nullable @Nullable Comparator<T> comparator, @NotNull @NotNull Collection<T> base) Create a linked set with all given elements.- Type Parameters:
T- generic type set- Parameters:
comparator- sort comparator instancebase- the base collection content- Returns:
- a linked set with all elements
-
enumSetOf
@NotNull public static <T extends Enum<T>> @NotNull Set<T> enumSetOf(@NotNull @NotNull Class<T> cls) Create an enum set with all enum elements.- Type Parameters:
T- generic enum type- Parameters:
cls- the enum class to check- Returns:
- an enum set with all enum elements
-
mapOf
Create a read-only empty map.- Type Parameters:
K- key entry typeV- value entry type- Returns:
- a read-only map with all content
-
mapOf
@SafeVarargs @NotNull public static <K,V> @Unmodifiable @NotNull Map<K,V> mapOf(Map.Entry<K, V> @NotNull ... entries) Create a read-only map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
entries- the elements to insert- Returns:
- a read-only map with all content
-
mapOf
@SafeVarargs @NotNull public static <K,V> @Unmodifiable @NotNull Map<K,V> mapOf(Pair<K, V> @NotNull ... pairs) Create a read-only map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
pairs- the elements to insert- Returns:
- a read-only map with all content
-
mutableMapOf
Create a mutable map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Returns:
- a mutable map with all content
-
mutableMapOf
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> mutableMapOf(Map.Entry<K, V> @NotNull ... entries) Create a mutable map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
entries- the elements to insert- Returns:
- a mutable map with all content
-
mutableMapOf
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> mutableMapOf(Pair<K, V> @NotNull ... pairs) Create a mutable map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
pairs- the elements to insert- Returns:
- a mutable map with all content
-
weakMapOf
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> weakMapOf(Map.Entry<K, V> @NotNull ... entries) Create a weak-reference map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
entries- the elements to insert- Returns:
- a weak map with all content
-
weakMapOf
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> weakMapOf(Pair<K, V> @NotNull ... pairs) Create a weak-reference map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
pairs- the elements to insert- Returns:
- a weak map with all content
-
linkedMapOf
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> linkedMapOf(Map.Entry<K, V> @NotNull ... entries) Create a linked map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
entries- the elements to insert- Returns:
- a linked map with all content
-
linkedMapOf
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> linkedMapOf(Pair<K, V> @NotNull ... pairs) Create a linked map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
pairs- the elements to insert- Returns:
- a linked map with all content
-
entryOf
InstantiateMap.Entryto more easily generate data maps.- Type Parameters:
K- entry key typeV- entry value type- Parameters:
key- entry keyvalue- entry value- Returns:
- a read-only configured entry
-
mutableEntryOf
InstantiateMap.Entryto more easily generate data maps.- Type Parameters:
K- entry key typeV- entry value type- Parameters:
key- entry keyvalue- entry value- Returns:
- a mutable configured entry
-
combine
@SafeVarargs @NotNull public static <T> @NotNull Collection<T> combine(boolean excludeDuplicates, List<T> @NotNull ... lts) Combine different lists into a single collection- Type Parameters:
T- generic collection type- Parameters:
excludeDuplicates- remove all duplicate itemslts- the lists you want to merge- Returns:
- returns a single collection with all the elements of the passed lists
-
combine
Combine different lists into a single collection- Type Parameters:
T- generic collection type- Parameters:
lts- the lists you want to merge- Returns:
- returns a single collection with all the elements of the passed lists
-
combine
Combine different sets into a single collection- Type Parameters:
T- generic collection type- Parameters:
sets- the sets you want to merge- Returns:
- returns a single collection with all the elements of the passed sets
-