Package owl.collections
Class Collections3
- java.lang.Object
-
- owl.collections.Collections3
-
public final class Collections3 extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E> List<E>
add(List<? extends E> list, E element)
static <K,V>
Map<K,V>add(Map<K,V> map, K key, V value)
static <E> Set<E>
add(Set<E> set, E element)
static <E extends Comparable<? super E>>
intcompare(Set<? extends E> s1, Set<? extends E> s2)
static <K,V>
booleancontainsAll(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2)
This method is null-hostile.static <E1,E2>
voidforEachPair(Iterable<E1> iterable1, Iterable<E2> iterable2, BiConsumer<? super E1,? super E2> action)
static <K,V>
booleanhasDistinctValues(Map<K,V> map)
static <E> int
indexOf(List<Set<E>> sets, E element)
Returns the index of the first occurrence of the specified element in this list of sets, or -1 if this list does not contain the element.static <E> boolean
isDistinct(List<E> list)
static <E> List<E>
maximalElements(Collection<? extends E> elements, BiPredicate<? super E,? super E> isLessThan)
Computes a sub-list of elements which are maximal.static <E> Set<E>
ofNullable(E element)
static <E> List<Set<E>>
partition(Collection<? extends E> elements, BiPredicate<? super E,? super E> relation)
Partition the elements using the given relation.static <E extends Comparable<E>>
booleansorted(List<E> list)
static <E1,E2>
List<E2>transformList(List<E1> list, Function<E1,E2> transformer)
static <K1,K2>
Map<K2,BddSet>transformMap(Map<K1,BddSet> map, Function<K1,K2> transformer)
static <K1,K2,V>
Map<K2,V>transformMap(Map<K1,V> map, Function<K1,K2> transformer, BiFunction<? super V,? super V,? extends V> valueMerger)
static <E1,E2>
Set<E2>transformSet(Set<E1> set, Function<E1,E2> transformer)
static <E> Set<E>
union(Set<E> set1, Set<E> set2)
-
-
-
Method Detail
-
containsAll
public static <K,V> boolean containsAll(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2)
This method is null-hostile.
-
sorted
public static <E extends Comparable<E>> boolean sorted(List<E> list)
-
forEachPair
public static <E1,E2> void forEachPair(Iterable<E1> iterable1, Iterable<E2> iterable2, BiConsumer<? super E1,? super E2> action)
-
isDistinct
public static <E> boolean isDistinct(List<E> list)
-
hasDistinctValues
public static <K,V> boolean hasDistinctValues(Map<K,V> map)
-
ofNullable
public static <E> Set<E> ofNullable(@Nullable E element)
-
maximalElements
public static <E> List<E> maximalElements(Collection<? extends E> elements, BiPredicate<? super E,? super E> isLessThan)
Computes a sub-list of elements which are maximal. The iteration order is preserved. Does not support null elements.- Type Parameters:
E
- the type- Parameters:
elements
- the elementsisLessThan
- returns true is the first argument is less than the second argument. It is only required that the order is transitive. The reflexive hull is added automatically.- Returns:
- a sublist only containing maximal elements.
-
partition
public static <E> List<Set<E>> partition(Collection<? extends E> elements, BiPredicate<? super E,? super E> relation)
Partition the elements using the given relation.- Type Parameters:
E
- the element type.- Parameters:
elements
- the collection containing the elements that are group into partitions.relation
- the relation used to construct the partition. It is only required this relation is symmetric. The transitive and reflexive hull are computed automatically.- Returns:
- the partition.
-
transformList
public static <E1,E2> List<E2> transformList(List<E1> list, Function<E1,E2> transformer)
Creates a newList
by applying thetransformer
on each element oflist
.The implementation does not access
Collection.isEmpty()
orCollection.size()
), since computing these values on live views might be expensive and cause a full traversal.- Type Parameters:
E1
- the element type of the inputE2
- the element type of the return value- Parameters:
list
- the input list.transformer
- the translator function. It is not allowed to returnnull
, since the used data-structures might be null-hostile.- Returns:
- a new list containing all transformed objects
-
transformMap
public static <K1,K2> Map<K2,BddSet> transformMap(Map<K1,BddSet> map, Function<K1,K2> transformer)
-
transformMap
public static <K1,K2,V> Map<K2,V> transformMap(Map<K1,V> map, Function<K1,K2> transformer, BiFunction<? super V,? super V,? extends V> valueMerger)
-
transformSet
public static <E1,E2> Set<E2> transformSet(Set<E1> set, Function<E1,E2> transformer)
Creates a newSet
by applying thetransformer
on each element ofset
.The implementation does not access
Collection.isEmpty()
orCollection.size()
), since computing these values on live views might be expensive and cause a full traversal.- Type Parameters:
E1
- the element type of the inputE2
- the element type of the return value- Parameters:
set
- the input set.transformer
- the translator function. It is not allowed to returnnull
, since the used data-structures might be null-hostile.- Returns:
- a new set containing all transformed objects
-
compare
public static <E extends Comparable<? super E>> int compare(Set<? extends E> s1, Set<? extends E> s2)
-
indexOf
public static <E> int indexOf(List<Set<E>> sets, E element)
Returns the index of the first occurrence of the specified element in this list of sets, or -1 if this list does not contain the element. More formally, returns the lowest indexi
such thatget(i).contains(o)
, or -1 if there is no such index.- Parameters:
sets
- list of setselement
- element to search for- Returns:
- the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element
-
-