Class CollectionUtils

java.lang.Object
org.aksw.commons.collections.CollectionUtils

public class CollectionUtils extends Object
User: raven Date: 4/17/11 Time: 12:36 AM
  • Constructor Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • newCollection

      public static <T, C extends Collection<T>> C newCollection(Supplier<C> collectionSupplier, Iterator<? extends T> itemIt)
      Create a new collection and initialize it with items from an iterator Mainly useful in cases where use of guava could cause issues (e.g. hadoop/spark)
    • newCollection

      public static <T, C extends Collection<T>> C newCollection(Supplier<C> collectionSupplier, Iterable<? extends T> items)
      Create a new collection and initialize it with items from an iterable Mainly useful in cases where use of guava could cause issues (e.g. hadoop/spark)
    • safeGetFirst

      public static <S, T extends Iterable<S>> Iterable<S> safeGetFirst(Iterable<T> iterable)
      Given an iterable A whose elements are iterables, this method will return the first element of A. If no such element exist, an empty iterable is returned rather than null.
      Type Parameters:
      S -
      T -
      Parameters:
      iterable -
      Returns:
    • chunk

      public static <T> List<List<T>> chunk(Iterable<T> col, int batchSize)
    • argmaxInt

      public static <T> Optional<T> argmaxInt(Collection<T> xs, ToIntFunction<? super T> score)