Package htsjdk.samtools.util
Class CollectionUtil
java.lang.Object
htsjdk.samtools.util.CollectionUtil
Small utility methods for dealing with collection classes.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A defaulting map, which returns a default value when a value that does not exist in the map is looked up.static class
Simple multi-map for convenience of storing collections in map values.static class
Deprecated.use Collectors.groupingBy instead -
Field Summary
Modifier and TypeFieldDescriptionstatic final Comparator<Object>
Simple case-insensitive lexical comparator of objects using theirObject.toString()
value. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
getSoleElement
(Collection<T> items) static String
join
(Collection<?> items, String inBetween) Construct a string by toString()ing each item in the collection with inBetween between each item.static <T> Collection<T>
makeCollection
(Iterator<T> i) static <T> List<T>
makeList
(T... list) static <T> Set<T>
makeSet
(T... list) static <K,
V> Map<K, Collection<V>> partition
(Collection<V> collection, CollectionUtil.Partitioner<V, K> p) Deprecated.use java8 .stream().collect(Collectors.groupingBy(()-> function)) insteadstatic <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.
-
Field Details
-
OBJECT_TOSTRING_COMPARATOR
Simple case-insensitive lexical comparator of objects using theirObject.toString()
value.
-
-
Constructor Details
-
CollectionUtil
public CollectionUtil()
-
-
Method Details
-
makeList
-
makeSet
-
makeCollection
-
join
Construct a string by toString()ing each item in the collection with inBetween between each item. -
getSoleElement
-
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)) insteadPartitions 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.
-