Class CollectionUtil

java.lang.Object
htsjdk.samtools.util.CollectionUtil

public class CollectionUtil extends Object
Small utility methods for dealing with collection classes.
  • Field Details

    • OBJECT_TOSTRING_COMPARATOR

      public static final Comparator<Object> OBJECT_TOSTRING_COMPARATOR
      Simple case-insensitive lexical comparator of objects using their Object.toString() value.
  • Constructor Details

    • CollectionUtil

      public CollectionUtil()
  • Method Details

    • makeList

      public static <T> List<T> makeList(T... list)
    • makeSet

      public static <T> Set<T> makeSet(T... list)
    • makeCollection

      public static <T> Collection<T> makeCollection(Iterator<T> i)
    • join

      public static String join(Collection<?> items, String inBetween)
      Construct a string by toString()ing each item in the collection with inBetween between each item.
    • getSoleElement

      public static <T> T getSoleElement(Collection<T> items)
    • partition

      @Deprecated public static <K, V> Map<K,Collection<V>> partition(Collection<V> collection, CollectionUtil.Partitioner<V,K> p)
      Deprecated.
      use java8 .stream().collect(Collectors.groupingBy(()-> function)) instead
      Partitions a collection into groups based on a characteristics of that group. Partitions are embodied in a map, whose keys are the value of that characteristic, and the values are the partition of elements whose characteristic evaluate to that key.
    • partition

      public static <K, V> Map<K,Collection<V>> partition(Collection<V> collection, Function<? super V,? extends K> keyer)
      Partitions a collection into groups based on a characteristics of that group. Partitions are embodied in a map, whose keys are the value of that characteristic, and the values are the partition of elements whose characteristic evaluate to that key.