Package net.dv8tion.jda.api.utils.cache
Interface SortedSnowflakeCacheView<T extends Comparable<? super T> & ISnowflake>
- Type Parameters:
T
- The entity type
- All Superinterfaces:
CacheView<T>
,Iterable<T>
,SnowflakeCacheView<T>
public interface SortedSnowflakeCacheView<T extends Comparable<? super T> & ISnowflake>
extends SnowflakeCacheView<T>
Specialized
In this specialization
CacheView
for entities that occur in a specified order.
In this specialization
Iterable.forEach(Consumer)
will copy the underlying data store
in order to preserve order on iterations, use forEachUnordered(Consumer)
to avoid this overhead.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.utils.cache.CacheView
CacheView.SimpleCacheView<T>
-
Method Summary
Modifier and TypeMethodDescriptionasSet()
Creates an immutable snapshot of the current cache state.void
forEachUnordered
(Consumer<? super T> action) Behavior similar toIterable.forEach(Consumer)
but does not preserve order.Behavior similar toCacheView.parallelStream()
which does not preserve order.Behavior similar toCacheView.stream()
which does not preserve order.Methods inherited from interface net.dv8tion.jda.api.utils.cache.CacheView
acceptStream, applyStream, asList, collect, getElementsByName, getElementsByName, isEmpty, lockedIterator, parallelStream, size, stream
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface net.dv8tion.jda.api.utils.cache.SnowflakeCacheView
getElementById, getElementById
-
Method Details
-
forEachUnordered
Behavior similar toIterable.forEach(Consumer)
but does not preserve order.
This will not copy the data store as sorting is not needed.- Specified by:
forEachUnordered
in interfaceCacheView<T extends Comparable<? super T> & ISnowflake>
- Parameters:
action
- The action to perform- Throws:
NullPointerException
- If provided with null- Since:
- 4.0.0
-
asSet
Description copied from interface:CacheView
Creates an immutable snapshot of the current cache state.
This will copy all elements contained in this cache into a set.- Specified by:
asSet
in interfaceCacheView<T extends Comparable<? super T> & ISnowflake>
- Returns:
- Immutable set of cached elements
-
streamUnordered
Behavior similar toCacheView.stream()
which does not preserve order.- Returns:
- Stream of the contained elements
- Since:
- 4.0.0
-
parallelStreamUnordered
Behavior similar toCacheView.parallelStream()
which does not preserve order.- Returns:
- (Parallel) Stream of contained elements
- Since:
- 4.0.0
-