Class Collections

java.lang.Object
one.pkg.tiny.utils.Collections

public class Collections extends Object
The Collections class provides utility methods for creating optimized data structures such as maps, sets, and lists.

It dynamically determines whether to use the optimized implementations from the FastUtil library or standard Java collections based on the availability of FastUtil classes.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <K, V> void
    entryForEach(@NotNull Map<K,V> map, @NotNull Consumer<? super Map.Entry<K,V>> consumer)
    Iterates over each entry in the provided map and applies the given consumer action to each entry.
    static <T> List<T>
    Creates a new empty list instance.
    static <T> List<T>
    newArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int size)
    Creates a new List instance with the specified initial size.
    static <T> List<T>
    newArrayList(@NotNull Iterable<? extends T> elements)
    Creates a new ArrayList containing the elements from the provided Iterable.
    static <T> List<T>
    newArrayList(@NotNull Collection<? extends T> elements)
    Creates a new list containing the elements from the specified collection.
    static <T> List<T>
    newArrayList(@NotNull Iterator<? extends T> elements)
    Creates a new List containing all elements from the given Iterator.
    static <T> List<T>
    newArrayList(@NotNull T... elements)
    Creates a new array-backed List containing the provided elements.
    static List<Boolean>
    Creates and returns a new list to store Boolean values.
    static List<Boolean>
    newBooleanArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new list of Booleans with the specified initial capacity.
    static List<Boolean>
    newBooleanArrayList(boolean... initialValues)
    Creates a new list of Boolean objects initialized with the provided boolean values.
    static <K> Map<K,Boolean>
    Creates and returns a new Map instance where the values are of type Boolean.
    static <K> Map<K,Boolean>
    newBooleanHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new Map instance with keys of type K and boolean values.
    static List<Byte>
    Creates and returns a new list of Byte elements.
    static List<Byte>
    newByteArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new list to hold Byte elements with the specified initial capacity.
    static List<Byte>
    newByteArrayList(byte... initialValues)
    Creates a new list of Byte objects initialized with the specified byte values.
    static List<Character>
    Creates and returns a new list of characters.
    static List<Character>
    newCharArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates and returns a new list of Characters with the specified initial capacity.
    static List<Character>
    newCharArrayList(char... initialValues)
    Creates a new List of Character elements from the given array of primitive char values.
    static List<Double>
    Creates and returns a new instance of a list that stores Double values.
    static List<Double>
    newDoubleArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new list capable of storing double values with the specified initial capacity.
    static List<Double>
    newDoubleArrayList(double... initialValues)
    Creates a new list of Doubles initialized with the given double values.
    static <K> Map<K,Double>
    Creates a new map with generic keys and double values.
    static <K> Map<K,Double>
    newDoubleHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new hash map with keys of type K and values of type Double.
    static List<Float>
    Creates a new list of Float type.
    static List<Float>
    newFloatArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new instance of a list to hold float values with the specified initial capacity.
    static List<Float>
    newFloatArrayList(float... initialValues)
    Creates a new list of Floats containing the provided initial values.
    static <K> Map<K,Float>
    Creates a new map with keys of type K and values of type Float.
    static <K> Map<K,Float>
    newFloatHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new map with keys of generic type K and float values.
    static <K, V> Map<K,V>
    Creates and returns a new hash map with default settings.
    static <K, V> Map<K,V>
    newHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new hash map with the specified initial capacity.
    static <K, V> Map<K,V>
    newHashMap(@NotNull Map<K,V> map)
    Creates a new HashMap instance and populates it with the entries from the provided map.
    static <T> Set<T>
    Creates a new empty HashSet instance.
    static <T> Set<T>
    newHashSet(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new hash set with the specified initial capacity.
    static <T> Set<T>
    newHashSet(@NotNull T... elements)
    Creates a new HashSet containing the provided elements.
    static List<Integer>
    Creates and returns a new instance of a list that stores integers.
    static List<Integer>
    newIntArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new list of integers with the specified initial capacity.
    static List<Integer>
    newIntArrayList(int... initialValues)
    Creates a new list of integers initialized with the given values.
    static <K> Map<K,Integer>
    Creates a new hash map that maps keys of type K to integer values.
    static <K> Map<K,Integer>
    newIntHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new hash map where keys are of type K and values are of type Integer.
    static <K, V> Map<K,V>
    Creates and returns a new instance of a LinkedHashMap.
    static <K, V> Map<K,V>
    newLinkedHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new LinkedHashMap with the specified initial capacity.
    static <K, V> Map<K,V>
    newLinkedHashMap(@NotNull Map<K,V> map)
    Creates a new LinkedHashMap or a fastutil Object2ObjectLinkedOpenHashMap based on the specified map.
    static List<Long>
    Creates a new list of Long type.
    static List<Long>
    newLongArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new instance of a list that can hold Long objects with the specified initial capacity.
    static List<Long>
    newLongArrayList(long... initialValues)
    Creates a new List of Longs initialized with the given long values.
    static <K> Map<K,Long>
    Creates and returns a new map instance where the keys are of generic type K, and the values are of type Long.
    static <K> Map<K,Long>
    newLongHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new hash map with keys of type K and values of type Long.
    static List<Short>
    Creates and returns a new instance of a list that can store Short objects.
    static List<Short>
    newShortArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a new list of Short objects with the specified initial capacity.
    static List<Short>
    newShortArrayList(short... initialValues)
    Creates a new List of Short values, optionally initializing it with the provided short values.
    static <T> Set<T>
    newTreeSet(@NotNull Collection<? extends T> c)
    Creates a new TreeSet with the elements provided in the specified collection.
    static <T> Set<T>
    newTreeSetRB(@NotNull Collection<? extends T> c)
    Creates a new TreeSet instance with the elements provided in the specified collection.
    static <T> Set<T>
    Creates a new unmodifiable empty set.
    static <T> Set<T>
    newUnmodifiableHashSet(@NotNull Set<T> set)
    Creates a new unmodifiable hash set containing the elements of the provided set.
    static <T> Set<T>
    newUnmodifiableHashSet(@NotNull T... elements)
    Creates a new unmodifiable Set that contains the specified elements.
    static <T> List<T>
    Creates a new unmodifiable list.
    static <T> List<T>
    newUnmodifiableList(@NotNull List<T> list)
    Creates a new unmodifiable list from the provided list.
    static <T> List<T>
    newUnmodifiableList(@NotNull T... elements)
    Creates a new unmodifiable list containing the specified elements.
    static <K, V> boolean
    removeIf(@NotNull Map<K,V> map, @NotNull Predicate<? super Map.Entry<K,V>> filter)
    Removes all entries from the specified map that satisfy the provided predicate.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Collections

      public Collections()
  • Method Details

    • newIntHashMap

      public static <K> Map<K,Integer> newIntHashMap()
      Creates a new hash map that maps keys of type K to integer values.
      Type Parameters:
      K - the type of keys maintained by this map
      Returns:
      a new map that maps keys of type K to integers
    • newIntHashMap

      public static <K> Map<K,Integer> newIntHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new hash map where keys are of type K and values are of type Integer.
      Parameters:
      initialCapacity - the initial capacity of the hash map. Must be a non-negative integer.
      Returns:
      a new map instance with keys of type K and values of type Integer.
    • newLongHashMap

      public static <K> Map<K,Long> newLongHashMap()
      Creates and returns a new map instance where the keys are of generic type K, and the values are of type Long.
      Type Parameters:
      K - the type of keys maintained by the map
      Returns:
      a newly created map with generic key type K and Long values
    • newLongHashMap

      public static <K> Map<K,Long> newLongHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new hash map with keys of type K and values of type Long.
      Type Parameters:
      K - the type of keys to be used in the map
      Parameters:
      initialCapacity - the initial capacity of the hash map; must be greater than or equal to 0
      Returns:
      a new hash map instance with the specified initial capacity, either using a specialized implementation or a standard HashMap
    • newFloatHashMap

      public static <K> Map<K,Float> newFloatHashMap()
      Creates a new map with keys of type K and values of type Float.
      Type Parameters:
      K - the type of keys in the map
      Returns:
      a new map capable of storing keys of type K and values of type Float
    • newFloatHashMap

      public static <K> Map<K,Float> newFloatHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new map with keys of generic type K and float values.
      Type Parameters:
      K - the type of keys maintained by the map
      Parameters:
      initialCapacity - the initial capacity of the map; must be non-negative
      Returns:
      a new map instance with the respective initial capacity
    • newDoubleHashMap

      public static <K> Map<K,Double> newDoubleHashMap()
      Creates a new map with generic keys and double values.
      Type Parameters:
      K - the type of keys maintained by this map
      Returns:
      a new map with keys of type K and values of type Double
    • newDoubleHashMap

      public static <K> Map<K,Double> newDoubleHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new hash map with keys of type K and values of type Double.
      Parameters:
      initialCapacity - the initial capacity of the map. Must be a non-negative integer.
      Returns:
      a new map of type Map<K, Double> with the specified initial capacity.
    • newBooleanHashMap

      public static <K> Map<K,Boolean> newBooleanHashMap()
      Creates and returns a new Map instance where the values are of type Boolean.
      Type Parameters:
      K - the type of the keys in the map
      Returns:
      a new Map instance with Boolean values
    • newBooleanHashMap

      public static <K> Map<K,Boolean> newBooleanHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new Map instance with keys of type K and boolean values.
      Parameters:
      initialCapacity - the initial capacity of the map; must be a non-negative integer.
      Returns:
      a new Map instance with the specified initial capacity.
    • newHashMap

      public static <K, V> Map<K,V> newHashMap()
      Creates and returns a new hash map with default settings.
      Type Parameters:
      K - the type of keys maintained by this map
      V - the type of mapped values
      Returns:
      a new instance of a hash map
    • newHashMap

      public static <K, V> Map<K,V> newHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new hash map with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the hash map; must be a non-negative integer
      Returns:
      a new instance of a hash map with the given initial capacity
    • newHashMap

      public static <K, V> Map<K,V> newHashMap(@NotNull @NotNull Map<K,V> map)
      Creates a new HashMap instance and populates it with the entries from the provided map.
      Parameters:
      map - the map whose entries are to be added to the newly created map; must not be null
      Returns:
      a new map containing all entries from the provided map
    • newLinkedHashMap

      public static <K, V> Map<K,V> newLinkedHashMap()
      Creates and returns a new instance of a LinkedHashMap.
      Type Parameters:
      K - the type of keys maintained by the map
      V - the type of values stored in the map
      Returns:
      a new instance of a map, either LinkedHashMap or Object2ObjectLinkedOpenHashMap
    • newLinkedHashMap

      public static <K, V> Map<K,V> newLinkedHashMap(@NotNull @NotNull Map<K,V> map)
      Creates a new LinkedHashMap or a fastutil Object2ObjectLinkedOpenHashMap based on the specified map.
      Parameters:
      map - the input map whose entries are to be copied to the newly created map; must not be null
      Returns:
      a new map containing the entries from the given map, maintaining insertion order
    • newLinkedHashMap

      public static <K, V> Map<K,V> newLinkedHashMap(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new LinkedHashMap with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the map, must be non-negative and within the valid range.
      Returns:
      a new instance of a map implementing LinkedHashMap with the specified initial capacity.
    • newHashSet

      public static <T> Set<T> newHashSet()
      Creates a new empty HashSet instance.
      Type Parameters:
      T - the type of elements maintained by the set.
      Returns:
      a new empty Set instance.
    • newHashSet

      public static <T> Set<T> newHashSet(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new hash set with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the hash set; must be non-negative
      Returns:
      a newly created hash set instance with the specified initial capacity
    • newHashSet

      @SafeVarargs public static <T> Set<T> newHashSet(@NotNull @NotNull T... elements)
      Creates a new HashSet containing the provided elements.
      Parameters:
      elements - the elements to be added to the new HashSet; must not be null
      Returns:
      a new HashSet containing the specified elements
    • newUnmodifiableHashSet

      public static <T> Set<T> newUnmodifiableHashSet()
      Creates a new unmodifiable empty set.
      Type Parameters:
      T - the type of elements that the set can hold
      Returns:
      a new unmodifiable empty set
    • newUnmodifiableHashSet

      public static <T> Set<T> newUnmodifiableHashSet(@NotNull @NotNull Set<T> set)
      Creates a new unmodifiable hash set containing the elements of the provided set.
      Parameters:
      set - the input set whose elements will be included in the new unmodifiable set; must not be null
      Returns:
      an unmodifiable set containing the elements of the input set
    • newUnmodifiableHashSet

      @SafeVarargs public static <T> Set<T> newUnmodifiableHashSet(@NotNull @NotNull T... elements)
      Creates a new unmodifiable Set that contains the specified elements.
      Parameters:
      elements - the elements to be included in the set; cannot be null.
      Returns:
      an unmodifiable set containing the specified elements.
    • newTreeSet

      public static <T> Set<T> newTreeSet(@NotNull @NotNull Collection<? extends T> c)
      Creates a new TreeSet with the elements provided in the specified collection. Depending on the context, either a TreeSet or a ObjectAVLTreeSet from the fastutil library will be created and returned.
      Type Parameters:
      T - the type of elements maintained by the set
      Parameters:
      c - the collection whose elements are to be placed into the new set
      Returns:
      a newly created TreeSet containing the elements from the provided collection
    • newTreeSetRB

      public static <T> Set<T> newTreeSetRB(@NotNull @NotNull Collection<? extends T> c)
      Creates a new TreeSet instance with the elements provided in the specified collection. Depending on the configuration, it uses either a fastutil ObjectRBTreeSet or a standard TreeSet.
      Type Parameters:
      T - the type of elements maintained by the set
      Parameters:
      c - the collection whose elements are to be placed into the new set; must not be null
      Returns:
      a newly created TreeSet containing all elements of the specified collection
    • newArrayList

      public static <T> List<T> newArrayList()
      Creates a new empty list instance. The implementation type of the list returned depends on the runtime configuration.
      Type Parameters:
      T - The type of elements that the list will hold.
      Returns:
      A new instance of an empty List.
    • newUnmodifiableList

      public static <T> List<T> newUnmodifiableList()
      Creates a new unmodifiable list.
      Type Parameters:
      T - the type of elements in the list
      Returns:
      a new unmodifiable list instance
    • newUnmodifiableList

      public static <T> List<T> newUnmodifiableList(@NotNull @NotNull List<T> list)
      Creates a new unmodifiable list from the provided list.
      Parameters:
      list - the list from which the unmodifiable list is to be created; must not be null
      Returns:
      an unmodifiable list containing the same elements as the provided list
    • newUnmodifiableList

      @SafeVarargs public static <T> List<T> newUnmodifiableList(@NotNull @NotNull T... elements)
      Creates a new unmodifiable list containing the specified elements.
      Type Parameters:
      T - the type of elements in the list
      Parameters:
      elements - the elements to include in the unmodifiable list; must not be null
      Returns:
      an unmodifiable list containing the provided elements
    • newIntArrayList

      public static List<Integer> newIntArrayList()
      Creates and returns a new instance of a list that stores integers.
      Returns:
      a new list instance for storing integers, either an IntArrayList or an ArrayList based on the 'fastutil' flag.
    • newIntArrayList

      public static List<Integer> newIntArrayList(int... initialValues)
      Creates a new list of integers initialized with the given values.
      Parameters:
      initialValues - the integer values to initialize the list with
      Returns:
      a new list of integers containing the provided initial values
    • newIntArrayList

      public static List<Integer> newIntArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new list of integers with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the list, must be non-negative
      Returns:
      a new instance of a list of integers with the specified initial capacity
    • newLongArrayList

      public static List<Long> newLongArrayList()
      Creates a new list of Long type.
      Returns:
      a new list of Long elements, using a specific implementation based on the configuration.
    • newLongArrayList

      public static List<Long> newLongArrayList(long... initialValues)
      Creates a new List of Longs initialized with the given long values.
      Parameters:
      initialValues - an optional list of long values to initialize the list with
      Returns:
      a new List of Longs containing the given initial values
    • newLongArrayList

      public static List<Long> newLongArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new instance of a list that can hold Long objects with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the list. Must be a non-negative integer value.
      Returns:
      a List of Long objects with the specified initial capacity.
    • newFloatArrayList

      public static List<Float> newFloatArrayList()
      Creates a new list of Float type.
      Returns:
      a new list of Float type, using the specified implementation based on the 'fastutil' flag.
    • newFloatArrayList

      public static List<Float> newFloatArrayList(float... initialValues)
      Creates a new list of Floats containing the provided initial values.
      Parameters:
      initialValues - an array of float values to initialize the list with
      Returns:
      a List of Float containing the provided initial values
    • newFloatArrayList

      public static List<Float> newFloatArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new instance of a list to hold float values with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the list. Must be a non-negative integer.
      Returns:
      a list capable of storing float values, utilizing either a FastUtil implementation or a standard ArrayList based on the configuration.
    • newDoubleArrayList

      public static List<Double> newDoubleArrayList()
      Creates and returns a new instance of a list that stores Double values.
      Returns:
      a new list for storing Double values, either a FastUtil `DoubleArrayList` or a Java `ArrayList`
    • newDoubleArrayList

      public static List<Double> newDoubleArrayList(double... initialValues)
      Creates a new list of Doubles initialized with the given double values.
      Parameters:
      initialValues - an array of double values to initialize the list
      Returns:
      a new list containing the given double values
    • newDoubleArrayList

      public static List<Double> newDoubleArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new list capable of storing double values with the specified initial capacity.
      Parameters:
      initialCapacity - the initial size of the list, must be a non-negative integer.
      Returns:
      a new instance of a list that can contain double values, using FastUtil's implementation if available, otherwise a standard ArrayList.
    • newBooleanArrayList

      public static List<Boolean> newBooleanArrayList()
      Creates and returns a new list to store Boolean values.
      Returns:
      a new list instance for storing Boolean values, either a FastUtil BooleanArrayList or a standard ArrayList, depending on the fastutil flag.
    • newBooleanArrayList

      public static List<Boolean> newBooleanArrayList(boolean... initialValues)
      Creates a new list of Boolean objects initialized with the provided boolean values.
      Parameters:
      initialValues - the initial boolean values to populate the list with
      Returns:
      a list of Boolean objects containing the specified initial values
    • newBooleanArrayList

      public static List<Boolean> newBooleanArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new list of Booleans with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the list; must be non-negative.
      Returns:
      a new instance of a list of Booleans with the specified initial capacity.
    • newByteArrayList

      public static List<Byte> newByteArrayList()
      Creates and returns a new list of Byte elements.
    • newByteArrayList

      public static List<Byte> newByteArrayList(byte... initialValues)
      Creates a new list of Byte objects initialized with the specified byte values.
      Parameters:
      initialValues - the initial byte values to populate the list
      Returns:
      a new List of Byte objects containing the specified values
    • newByteArrayList

      public static List<Byte> newByteArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new list to hold Byte elements with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the list, must be between 0 and Integer.MAX_VALUE inclusive
      Returns:
      a new list capable of holding Byte elements with the specified initial capacity
    • newShortArrayList

      public static List<Short> newShortArrayList()
      Creates and returns a new instance of a list that can store Short objects.
      Returns:
      A new list for storing Short objects, either a fastutil ShortArrayList or a standard ArrayList.
    • newShortArrayList

      public static List<Short> newShortArrayList(short... initialValues)
      Creates a new List of Short values, optionally initializing it with the provided short values.
      Parameters:
      initialValues - an optional array of short values to initialize the list with
      Returns:
      a List containing the initial short values, or an empty list if no values are provided
    • newShortArrayList

      public static List<Short> newShortArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a new list of Short objects with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the list; must be a non-negative value.
      Returns:
      a new List of Short objects with the specified initial capacity.
    • newCharArrayList

      public static List<Character> newCharArrayList()
      Creates and returns a new list of characters.
      Returns:
      a new list of characters, either a `CharArrayList` or an `ArrayList` depending on the `fastutil` flag.
    • newCharArrayList

      public static List<Character> newCharArrayList(char... initialValues)
      Creates a new List of Character elements from the given array of primitive char values.
      Parameters:
      initialValues - an array of primitive char values to initialize the list with
      Returns:
      a new List containing the provided char values as Character objects
    • newCharArrayList

      public static List<Character> newCharArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates and returns a new list of Characters with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the list, must be a non-negative integer.
      Returns:
      a new list of Characters with the specified initial capacity.
    • newArrayList

      public static <T> List<T> newArrayList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int size)
      Creates a new List instance with the specified initial size.
      Type Parameters:
      T - The type of elements the list will contain.
      Parameters:
      size - The initial size of the list. Must be greater than or equal to 0.
      Returns:
      A new list instance with the specified size.
    • newArrayList

      @SafeVarargs public static <T> List<T> newArrayList(@NotNull @NotNull T... elements)
      Creates a new array-backed List containing the provided elements.
      Type Parameters:
      T - the type of elements in the list
      Parameters:
      elements - the elements to include in the new list; must not be null
      Returns:
      a new List containing the specified elements
    • newArrayList

      public static <T> List<T> newArrayList(@NotNull @NotNull Collection<? extends T> elements)
      Creates a new list containing the elements from the specified collection.
      Parameters:
      elements - the collection whose elements are to be placed into the new list, must not be null
      Returns:
      a new list containing the elements from the specified collection
    • newArrayList

      public static <T> List<T> newArrayList(@NotNull @NotNull Iterable<? extends T> elements)
      Creates a new ArrayList containing the elements from the provided Iterable. If the Iterable is a Collection, it leverages its properties to create the list more efficiently.
      Type Parameters:
      T - the type of elements in the list
      Parameters:
      elements - the Iterable whose elements are to be placed into the new list; must not be null
      Returns:
      a new ArrayList containing the elements from the provided Iterable
    • newArrayList

      public static <T> List<T> newArrayList(@NotNull @NotNull Iterator<? extends T> elements)
      Creates a new List containing all elements from the given Iterator.
      Type Parameters:
      T - the type of elements in the list
      Parameters:
      elements - an Iterator containing elements to be added to the list
      Returns:
      a new List containing all the elements from the given Iterator
    • entryForEach

      public static <K, V> void entryForEach(@NotNull @NotNull Map<K,V> map, @NotNull @NotNull Consumer<? super Map.Entry<K,V>> consumer)
      Iterates over each entry in the provided map and applies the given consumer action to each entry.
      Type Parameters:
      K - the type of keys maintained by the map
      V - the type of mapped values
      Parameters:
      map - the map whose entries are to be processed
      consumer - the action to be performed for each map entry
    • removeIf

      public static <K, V> boolean removeIf(@NotNull @NotNull Map<K,V> map, @NotNull @NotNull Predicate<? super Map.Entry<K,V>> filter)
      Removes all entries from the specified map that satisfy the provided predicate.
      Parameters:
      map - the map from which entries are to be removed based on the given predicate
      filter - the predicate that tests each entry; entries that satisfy this predicate are removed
      Returns:
      true if any entries were removed from the map, otherwise false