static <N> boolean
all(@Nullable Iterable<? extends N> list, Predicate<? super N> predicate)
Returns true if all elements of the iterable match the predicate.
static <N> boolean
any(@Nullable Iterable<? extends N> list, Predicate<? super N> predicate)
Returns true if any element of the iterable matches the predicate.
static <@NonNull T>
@Nullable T
asSingle(Set<@NonNull T> set)
If the set has a single element, returns it, otherwise returns null.
static <K,V>
Map<K,V>
associateBy(Collection<? extends @NonNull V> values, Function<? super V,? extends K> keyMapper)
static <K,V>
Map<K,V>
associateByTo(Map<K,V> collector, Collection<? extends @NonNull V> values, Function<? super V,? extends K> keyMapper)
static <K,V>
Map<K,V>
associateWith(Collection<? extends @NonNull K> keys, Function<? super K,? extends V> mapper)
static <K,V>
Map<K,V>
associateWithTo(Map<K,V> collector, Collection<? extends @NonNull K> keys, Function<? super K,? extends V> mapper)
static <K,V>
Map<K,V>
buildMap(Consumer<Map<K,V>> effect)
static <K,V>
Map<K,V>
buildMap(Map<K,V> initialMap, Consumer<Map<K,V>> effect)
static <T> List<T>
concatView(List<? extends T> head, List<? extends T> tail)
Returns a list view that pretends it is the concatenation of both lists.
static <T> List<T>
defensiveUnmodifiableCopy(List<? extends T> list)
Returns an unmodifiable copy of the list.
static <T> Set<T>
defensiveUnmodifiableCopyToSet(Collection<? extends T> list)
static <T> Set<T>
diff(Collection<? extends T> c1, Collection<? extends T> c2, Collection<? extends T>... rest)
Returns the set difference of the first collection with the other collections.
static <T> List<T>
drop(List<T> list, int n)
static <V> List<V>
emptyList()
Returns the empty list.
static <V,A,C>
C
finish(Collector<? super V,A,? extends C> collector, A acc)
Finish the accumulated value of the collector.
static <@NonNull K,V>
@Nullable K
getKeyOfValue(Map<@NonNull K,V> m, V v)
Returns the key that corresponds to the given value in the map, or null if it is not contained in the map.
static <T extends Enum<T>>
Set<T>
immutableEnumSet(T first, T... rest)
Returns an unmodifiable set containing the given elements.
static <T> Set<T>
immutableSetOf(T first, T... rest)
Returns an unmodifiable set containing the given elements.
static <T> Set<T>
intersect(Collection<? extends T> c1, Collection<? extends T> c2, Collection<? extends T>... rest)
Returns the set intersection of the given collections.
static @NonNull StringBuilder
joinCharsIntoStringBuilder(List<Chars> lines, String delimiter)
static <T> StringBuilder
joinOn(StringBuilder sb, Iterable<? extends T> iterable, BiConsumer<? super StringBuilder,? super T> appendItem, String delimiter)
Like
String.join(CharSequence, Iterable)
, except it appends on a preexisting
StringBuilder
.
static <T> List<T>
listOf(T first, T... rest)
static <T> List<T>
listOfNotNull(T t)
static <T> @NonNull List<T>
makeUnmodifiableAndNonNull(@Nullable List<? extends T> list)
static <T,R>
List<R>
map(Iterable<? extends T> from, Function<? super T,? extends R> f)
Map each element of the given iterable with the given function, and accumulates it into an unmodifiable list.
static <T,R>
List<R>
map(Collection<? extends T> from, Function<? super T,? extends R> f)
Map each element of the given collection with the given function, and accumulates it into an unmodifiable list.
static <T,R>
List<R>
map(Iterator<? extends T> from, Function<? super T,? extends R> f)
Map each element of the given iterator with the given function, and accumulates it into an unmodifiable list.
static <T,U,A,C>
C
map(Collector<? super U,A,? extends C> collector, Iterable<? extends T> from, Function<? super T,? extends U> f)
Map each element of the given iterable with the given function, and accumulates it into the collector.
static <T,U,A,C>
C
map(Collector<? super U,A,? extends C> collector, Iterator<? extends T> from, Function<? super T,? extends U> f)
Map each element of the given iterator with the given function, and accumulates it into the collector.
static <T,R>
List<R>
map(T[] from, Function<? super T,? extends R> f)
Map each element of the given array with the given function, and accumulates it into an unmodifiable list.
static <T,R>
List<@NonNull R>
mapNotNull(Iterable<? extends T> from, Function<? super T,? extends @Nullable R> f)
static <K,V>
Map<K,V>
mapOf(K k0, V v0)
static <K,V>
Map<K,V>
mapOf(K k1, V v1, K k2, V v2)
static <K,V>
void
mergeMaps(Map<K,V> result, Map<K,V> other, BinaryOperator<V> mergeFun)
Merge the second map into the first.
static <N> boolean
none(@Nullable Iterable<? extends N> list, Predicate<? super N> predicate)
Returns true if no element of the iterable matches the predicate.
static <V> List<V>
plus(List<V> list, V v)
Produce a new list with the elements of the first, and one additional item.
static <K,V>
Map<K,V>
plus(Map<K,V> m, K k, V v)
Produce a new map with the mappings of the first, and one additional mapping.
static <T> Set<T>
setOf(T first, T... rest)
Returns a set containing the given elements.
static <V> Set<V>
setUnion(Collection<? extends V> set, V first, V... newElements)
Returns an unmodifiable set containing the set union of the collection, and the new elements.
static <T> List<T>
take(List<T> list, int n)
static <T> Collector<T,?,List<T>>
toMutableList()
A collector that returns a mutable list.
static <T> Collector<T,?,Set<T>>
toMutableSet()
A collector that returns a mutable set.
static <T> Collector<T,?,org.pcollections.PSet<T>>
toPersistentSet()
A collectors that accumulates into a persistent set.
static <T> Collector<T,?,List<T>>
toUnmodifiableList()
A collector that returns an unmodifiable list.
static <T> Collector<T,?,Set<T>>
toUnmodifiableSet()
A collector that returns an unmodifiable set.
static <T> Set<T>
union(Collection<? extends T> c1, Collection<? extends T> c2, Collection<? extends T>... rest)
Returns the set union of the given collections.
static <K,V>
Map<K,V>
zip(List<? extends @NonNull K> from, List<? extends @NonNull V> to)
Returns a map associating each key in the first list to its corresponding value in the second.
public static <T> List<T> concatView(List<? extends T> head, List<? extends T> tail)
Returns a list view that pretends it is the concatenation of both lists. The returned view is unmodifiable. The implementation is pretty stupid and not optimized for repeated concatenation, but should be ok for smallish chains of random-access lists.
T
- Type of elements in both lists
head
- Head elements (to the left)
tail
- Tail elements (to the right)
@SafeVarargs public static <T> Set<T> union(Collection<? extends T> c1, Collection<? extends T> c2, Collection<? extends T>... rest)
Returns the set union of the given collections.
c1
- First collection
c2
- Second collection
@SafeVarargs public static <T> Set<T> intersect(Collection<? extends T> c1, Collection<? extends T> c2, Collection<? extends T>... rest)
Returns the set intersection of the given collections.
c1
- First collection
c2
- Second collection
@SafeVarargs public static <T> Set<T> diff(Collection<? extends T> c1, Collection<? extends T> c2, Collection<? extends T>... rest)
Returns the set difference of the first collection with the other collections.
c1
- First collection
c2
- Second collection
@SafeVarargs public static <T> Set<T> setOf(T first, T... rest)
Returns a set containing the given elements. No guarantee is made about mutability.
first
- First element
rest
- Following elements
@SafeVarargs public static <T> Set<T> immutableSetOf(T first, T... rest)
Returns an unmodifiable set containing the given elements.
first
- First element
rest
- Following elements
@SafeVarargs public static <T extends Enum<T>> Set<T> immutableEnumSet(T first, T... rest)
Returns an unmodifiable set containing the given elements.
first
- First element
rest
- Following elements
@SafeVarargs public static <T> List<T> listOf(T first, T... rest)
public static <K,V> Map<K,V> mapOf(K k0, V v0)
public static <K,V> Map<K,V> mapOf(K k1, V v1, K k2, V v2)
public static <T,R> List<@NonNull R> mapNotNull(Iterable<? extends T> from, Function<? super T,? extends @Nullable R> f)
public static <K,V> Map<K,V> plus(Map<K,V> m, K k, V v)
Produce a new map with the mappings of the first, and one additional mapping. The returned map may be unmodifiable.
public static <V> List<V> plus(List<V> list, V v)
Produce a new list with the elements of the first, and one additional item. The returned list is immutable.
public static <V> List<V> emptyList()
Returns the empty list.
@SafeVarargs public static <V> Set<V> setUnion(Collection<? extends V> set, V first, V... newElements)
Returns an unmodifiable set containing the set union of the collection, and the new elements.
public static <@NonNull K,V> @Nullable K getKeyOfValue(Map<@NonNull K,V> m, V v)
Returns the key that corresponds to the given value in the map, or null if it is not contained in the map.
K
- Type of keys
V
- Type of values
m
- Map
v
- Value
NullPointerException
- If the entry is found, but the key is null
NullPointerException
- If the map is null
public static <K,V> Map<K,V> zip(List<? extends @NonNull K> from, List<? extends @NonNull V> to)
Returns a map associating each key in the first list to its corresponding value in the second.
IllegalArgumentException
- If the list size are mismatched
NullPointerException
- If either of the parameter is null, or any of the keys or values are null
public static <K,V> Map<K,V> associateWith(Collection<? extends @NonNull K> keys, Function<? super K,? extends V> mapper)
public static <K,V> Map<K,V> associateWithTo(Map<K,V> collector, Collection<? extends @NonNull K> keys, Function<? super K,? extends V> mapper)
public static <K,V> Map<K,V> associateBy(Collection<? extends @NonNull V> values, Function<? super V,? extends K> keyMapper)
public static <K,V> Map<K,V> associateByTo(Map<K,V> collector, Collection<? extends @NonNull V> values, Function<? super V,? extends K> keyMapper)
public static <T,R> List<R> map(Collection<? extends T> from, Function<? super T,? extends R> f)
Map each element of the given collection with the given function, and accumulates it into an unmodifiable list.
public static <T,R> List<R> map(Iterable<? extends T> from, Function<? super T,? extends R> f)
Map each element of the given iterable with the given function, and accumulates it into an unmodifiable list.
public static <T,R> List<R> map(T[] from, Function<? super T,? extends R> f)
Map each element of the given array with the given function, and accumulates it into an unmodifiable list.
public static <T,R> List<R> map(Iterator<? extends T> from, Function<? super T,? extends R> f)
Map each element of the given iterator with the given function, and accumulates it into an unmodifiable list.
public static <T,U,A,C> C map(Collector<? super U,A,? extends C> collector, Iterable<? extends T> from, Function<? super T,? extends U> f)
Map each element of the given iterable with the given function, and accumulates it into the collector.
public static <T,U,A,C> C map(Collector<? super U,A,? extends C> collector, Iterator<? extends T> from, Function<? super T,? extends U> f)
Map each element of the given iterator with the given function, and accumulates it into the collector.
public static <T> Collector<T,?,List<T>> toMutableList()
A collector that returns a mutable list. This contrasts with
Collectors.toList()
, which makes no guarantee about the mutability of the list.
T
- Type of accumulated values
public static <T> Collector<T,?,Set<T>> toMutableSet()
A collector that returns a mutable set. This contrasts with
Collectors.toSet()
, which makes no guarantee about the mutability of the set. The set preserves insertion order.
T
- Type of accumulated values
public static <T> Collector<T,?,List<T>> toUnmodifiableList()
A collector that returns an unmodifiable list. This contrasts with
Collectors.toList()
, which makes no guarantee about the mutability of the list.
Collectors::toUnmodifiableList
was only added in JDK 9.
T
- Type of accumulated values
public static <T> Collector<T,?,Set<T>> toUnmodifiableSet()
A collector that returns an unmodifiable set. This contrasts with
Collectors.toSet()
, which makes no guarantee about the mutability of the set.
Collectors::toUnmodifiableSet
was only added in JDK 9. The set preserves insertion order.
T
- Type of accumulated values
public static <T> Collector<T,?,org.pcollections.PSet<T>> toPersistentSet()
A collectors that accumulates into a persistent set.
T
- Type of accumulated values
public static <V,A,C> C finish(Collector<? super V,A,? extends C> collector, A acc)
Finish the accumulated value of the collector.
public static <T> List<T> listOfNotNull(T t)
public static <N> boolean any(@Nullable Iterable<? extends N> list, Predicate<? super N> predicate)
Returns true if any element of the iterable matches the predicate. Return false if the list is null or empty.
public static <N> boolean all(@Nullable Iterable<? extends N> list, Predicate<? super N> predicate)
Returns true if all elements of the iterable match the predicate. Return true if the list is null or empty.
public static <N> boolean none(@Nullable Iterable<? extends N> list, Predicate<? super N> predicate)
Returns true if no element of the iterable matches the predicate. Return true if the list is null or empty.
public static <@NonNull T> @Nullable T asSingle(Set<@NonNull T> set)
If the set has a single element, returns it, otherwise returns null. Obviously the set should not contain null elements.
public static <T> List<T> defensiveUnmodifiableCopy(List<? extends T> list)
Returns an unmodifiable copy of the list. This is to be preferred to
Collections.unmodifiableList(List)
if you don't trust the source of the list, because no one holds a reference to the buffer except the returned unmodifiable list.
T
- Type of items
list
- A list
public static <T> Set<T> defensiveUnmodifiableCopyToSet(Collection<? extends T> list)
public static <T> StringBuilder joinOn(StringBuilder sb, Iterable<? extends T> iterable, BiConsumer<? super StringBuilder,? super T> appendItem, String delimiter)
public static @NonNull StringBuilder joinCharsIntoStringBuilder(List<Chars> lines, String delimiter)
public static <K,V> void mergeMaps(Map<K,V> result, Map<K,V> other, BinaryOperator<V> mergeFun)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4