Class CollectionExtensionsKt
-
- All Implemented Interfaces:
public final class CollectionExtensionsKt
-
-
Method Summary
Modifier and Type Method Description final static <K extends Any, V extends Any> Sequence<Entry.Map<K, V>>
asSequence(Cache<K, V> $self)
Returns a sequence of all entries in the cache for lazy evaluation. final static <K extends Any, V extends Any> Map<K, V>
toMap(Cache<K, V> $self)
Converts the cache to a regular Map. final static <K extends Any, V extends Any> Map<K, V>
toMutableMap(Cache<K, V> $self)
Converts the cache to a mutable Map. final static <K extends Any, V extends Any> Map<K, V>
filterKeys(Cache<K, V> $self, Function1<K, Boolean> predicate)
Filters entries by key predicate. final static <K extends Any, V extends Any> Map<K, V>
filterValues(Cache<K, V> $self, Function1<V, Boolean> predicate)
Filters entries by value predicate. final static <K extends Any, V extends Any> Map<K, V>
filter(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Filters entries by key-value predicate. final static <K extends Any, V extends Any, R extends Any> Map<K, R>
mapValues(Cache<K, V> $self, Function1<V, R> transform)
Maps values to a new type. final static <K extends Any, V extends Any, R extends Any> Map<R, V>
mapKeys(Cache<K, V> $self, Function1<K, R> transform)
Maps keys to a new type. final static <K extends Any, V extends Any, R extends Any, S extends Any> Map<R, S>
map(Cache<K, V> $self, Function2<K, V, Pair<R, S>> transform)
Maps both keys and values to new types. final static <K extends Any, V extends Any> Map<K, V>
getAll(Cache<K, V> $self, Collection<K> keys)
Gets multiple values at once. final static <K extends Any, V extends Any> Map<K, V>
getAllPresent(Cache<K, V> $self, Collection<K> keys)
Gets multiple values at once, filtering out null values. final static <K extends Any, V extends Any> Entry.Map<K, V>
find(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Finds the first entry that matches the given predicate. final static <K extends Any, V extends Any> List<Entry.Map<K, V>>
findAll(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Finds all entries that match the given predicate. final static <K extends Any, V extends Any> Integer
count(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Counts the number of entries that match the given predicate. final static <K extends Any, V extends Any> Boolean
any(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Checks if any entry matches the given predicate. final static <K extends Any, V extends Any> Boolean
all(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Checks if all entries match the given predicate. final static <K extends Any, V extends Any, R extends Any> Map<R, List<Entry.Map<K, V>>>
groupBy(Cache<K, V> $self, Function2<K, V, R> keySelector)
Groups entries by the result of the given function. final static <K extends Any, V extends Any> Pair<List<Entry.Map<K, V>>, List<Entry.Map<K, V>>>
partition(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Partitions entries into two lists based on the given predicate. final static <K extends Any, V extends Any, R extends Comparable<R>> Entry.Map<K, V>
minByOrNull(Cache<K, V> $self, Function2<K, V, R> selector)
Returns the minimum entry based on the given comparator. final static <K extends Any, V extends Any, R extends Comparable<R>> Entry.Map<K, V>
maxByOrNull(Cache<K, V> $self, Function2<K, V, R> selector)
Returns the maximum entry based on the given comparator. final static <K extends Any, V extends Any> Unit
forEach(Cache<K, V> $self, Function2<K, V, Unit> action)
Performs the given action on each entry in the cache. final static <K extends Any, V extends Any> List<K>
keysList(Cache<K, V> $self)
Returns a list of all keys in the cache. final static <K extends Any, V extends Any> List<V>
valuesList(Cache<K, V> $self)
Returns a list of all values in the cache. final static <K extends Any, V extends Any> Boolean
isEmpty(Cache<K, V> $self)
Returns true if the cache is empty. final static <K extends Any, V extends Any> Boolean
isNotEmpty(Cache<K, V> $self)
Returns true if the cache is not empty. final static <K extends Any, V extends Any> Boolean
containsValue(Cache<K, V> $self, V value)
Returns true if the cache contains the given value. final static <K extends Any, V extends Any> Unit
putAll(Cache<K, V> $self, Map<K, V> map)
Puts all entries from the given map into the cache. final static <K extends Any, V extends Any> List<V>
removeAll(Cache<K, V> $self, Collection<K> keys)
Removes all entries with the given keys from the cache. final static <K extends Any, V extends Any> Unit
retainAll(Cache<K, V> $self, Collection<K> keysToKeep)
Retains only the entries with the given keys. final static <K extends Any, V extends Any> Integer
removeIf(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Removes all entries that match the given predicate. final static <K extends Any, V extends Any> V
getOrPut(Cache<K, V> $self, K key, SuspendFunction0<V> compute)
Gets the value for the given key, or computes and stores it if not present. final static <K extends Any, V extends Any> V
getOrDefault(Cache<K, V> $self, K key, V defaultValue)
Gets the value for the given key, or returns the default value if not present. final static <K extends Any, V extends Any> V
getOrPutValue(Cache<K, V> $self, K key, Function0<V> defaultValue)
Gets the value for the key or puts and returns the default value. -
-
Method Detail
-
asSequence
final static <K extends Any, V extends Any> Sequence<Entry.Map<K, V>> asSequence(Cache<K, V> $self)
Returns a sequence of all entries in the cache for lazy evaluation.
-
toMap
final static <K extends Any, V extends Any> Map<K, V> toMap(Cache<K, V> $self)
Converts the cache to a regular Map.
-
toMutableMap
final static <K extends Any, V extends Any> Map<K, V> toMutableMap(Cache<K, V> $self)
Converts the cache to a mutable Map.
-
filterKeys
final static <K extends Any, V extends Any> Map<K, V> filterKeys(Cache<K, V> $self, Function1<K, Boolean> predicate)
Filters entries by key predicate.
-
filterValues
final static <K extends Any, V extends Any> Map<K, V> filterValues(Cache<K, V> $self, Function1<V, Boolean> predicate)
Filters entries by value predicate.
-
filter
final static <K extends Any, V extends Any> Map<K, V> filter(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Filters entries by key-value predicate.
-
mapValues
final static <K extends Any, V extends Any, R extends Any> Map<K, R> mapValues(Cache<K, V> $self, Function1<V, R> transform)
Maps values to a new type.
-
mapKeys
final static <K extends Any, V extends Any, R extends Any> Map<R, V> mapKeys(Cache<K, V> $self, Function1<K, R> transform)
Maps keys to a new type.
-
map
final static <K extends Any, V extends Any, R extends Any, S extends Any> Map<R, S> map(Cache<K, V> $self, Function2<K, V, Pair<R, S>> transform)
Maps both keys and values to new types.
-
getAll
final static <K extends Any, V extends Any> Map<K, V> getAll(Cache<K, V> $self, Collection<K> keys)
Gets multiple values at once.
-
getAllPresent
final static <K extends Any, V extends Any> Map<K, V> getAllPresent(Cache<K, V> $self, Collection<K> keys)
Gets multiple values at once, filtering out null values.
-
find
final static <K extends Any, V extends Any> Entry.Map<K, V> find(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Finds the first entry that matches the given predicate.
-
findAll
final static <K extends Any, V extends Any> List<Entry.Map<K, V>> findAll(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Finds all entries that match the given predicate.
-
count
final static <K extends Any, V extends Any> Integer count(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Counts the number of entries that match the given predicate.
-
any
final static <K extends Any, V extends Any> Boolean any(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Checks if any entry matches the given predicate.
-
all
final static <K extends Any, V extends Any> Boolean all(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Checks if all entries match the given predicate.
-
groupBy
final static <K extends Any, V extends Any, R extends Any> Map<R, List<Entry.Map<K, V>>> groupBy(Cache<K, V> $self, Function2<K, V, R> keySelector)
Groups entries by the result of the given function.
-
partition
final static <K extends Any, V extends Any> Pair<List<Entry.Map<K, V>>, List<Entry.Map<K, V>>> partition(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Partitions entries into two lists based on the given predicate.
-
minByOrNull
final static <K extends Any, V extends Any, R extends Comparable<R>> Entry.Map<K, V> minByOrNull(Cache<K, V> $self, Function2<K, V, R> selector)
Returns the minimum entry based on the given comparator.
-
maxByOrNull
final static <K extends Any, V extends Any, R extends Comparable<R>> Entry.Map<K, V> maxByOrNull(Cache<K, V> $self, Function2<K, V, R> selector)
Returns the maximum entry based on the given comparator.
-
forEach
final static <K extends Any, V extends Any> Unit forEach(Cache<K, V> $self, Function2<K, V, Unit> action)
Performs the given action on each entry in the cache.
-
keysList
final static <K extends Any, V extends Any> List<K> keysList(Cache<K, V> $self)
Returns a list of all keys in the cache.
-
valuesList
final static <K extends Any, V extends Any> List<V> valuesList(Cache<K, V> $self)
Returns a list of all values in the cache.
-
isEmpty
final static <K extends Any, V extends Any> Boolean isEmpty(Cache<K, V> $self)
Returns true if the cache is empty.
-
isNotEmpty
final static <K extends Any, V extends Any> Boolean isNotEmpty(Cache<K, V> $self)
Returns true if the cache is not empty.
-
containsValue
final static <K extends Any, V extends Any> Boolean containsValue(Cache<K, V> $self, V value)
Returns true if the cache contains the given value.
-
putAll
final static <K extends Any, V extends Any> Unit putAll(Cache<K, V> $self, Map<K, V> map)
Puts all entries from the given map into the cache.
-
removeAll
final static <K extends Any, V extends Any> List<V> removeAll(Cache<K, V> $self, Collection<K> keys)
Removes all entries with the given keys from the cache.
-
retainAll
final static <K extends Any, V extends Any> Unit retainAll(Cache<K, V> $self, Collection<K> keysToKeep)
Retains only the entries with the given keys.
-
removeIf
final static <K extends Any, V extends Any> Integer removeIf(Cache<K, V> $self, Function2<K, V, Boolean> predicate)
Removes all entries that match the given predicate.
-
getOrPut
final static <K extends Any, V extends Any> V getOrPut(Cache<K, V> $self, K key, SuspendFunction0<V> compute)
Gets the value for the given key, or computes and stores it if not present. This suspending function provides a thread-safe way to implement the "check-then-act" pattern.
-
getOrDefault
final static <K extends Any, V extends Any> V getOrDefault(Cache<K, V> $self, K key, V defaultValue)
Gets the value for the given key, or returns the default value if not present.
-
getOrPutValue
final static <K extends Any, V extends Any> V getOrPutValue(Cache<K, V> $self, K key, Function0<V> defaultValue)
Gets the value for the key or puts and returns the default value.
-
-
-
-