Class CollectionUtils

java.lang.Object
org.pgpainless.util.CollectionUtils

public final class CollectionUtils extends Object
  • Method Details

    • iteratorToList

      public static <I> List<I> iteratorToList(Iterator<I> iterator)
      Return all items returned by the Iterator as a List.
      Type Parameters:
      I - type
      Parameters:
      iterator - iterator
      Returns:
      list
    • concat

      public static <T> T[] concat(T t, T[] ts)
      Return a new array which contains
      t
      as first element, followed by the elements of
      ts
      .
      Type Parameters:
      T - type
      Parameters:
      t - head
      ts - tail
      Returns:
      t and ts as array
    • contains

      public static <T> boolean contains(T[] ts, T t)
      Return true, if the given array
      ts
      contains the element
      t
      .
      Type Parameters:
      T - type
      Parameters:
      ts - elements
      t - searched element
      Returns:
      true if ts contains t, false otherwise
    • addAll

      public static <T> void addAll(Iterator<T> iterator, Collection<T> collection)
      Add all items from the iterator to the collection.
      Type Parameters:
      T - type of item
      Parameters:
      iterator - iterator to gather items from
      collection - collection to add items to