Package net.dv8tion.jda.api.utils.cache
Interface SortedSnowflakeCacheView<T extends java.lang.Comparable<? super T> & ISnowflake>
-
- Type Parameters:
T
- The entity type
- All Superinterfaces:
CacheView<T>
,java.lang.Iterable<T>
,SnowflakeCacheView<T>
public interface SortedSnowflakeCacheView<T extends java.lang.Comparable<? super T> & ISnowflake> extends SnowflakeCacheView<T>
SpecializedCacheView
for entities that occur in a specified order.
In this specializationIterable.forEach(Consumer)
will copy the underlying data store in order to preserve order on iterations, useforEachUnordered(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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.NavigableSet<T>
asSet()
Creates an immutable snapshot of the current cache state.void
forEachUnordered(java.util.function.Consumer<? super T> action)
Behavior similar toIterable.forEach(Consumer)
but does not preserve order.java.util.stream.Stream<T>
parallelStreamUnordered()
Behavior similar toCacheView.parallelStream()
which does not preserve order.java.util.stream.Stream<T>
streamUnordered()
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 net.dv8tion.jda.api.utils.cache.SnowflakeCacheView
getElementById, getElementById
-
-
-
-
Method Detail
-
forEachUnordered
void forEachUnordered(@Nonnull java.util.function.Consumer<? super T> action)
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 java.lang.Comparable<? super T> & ISnowflake>
- Parameters:
action
- The action to perform- Throws:
java.lang.NullPointerException
- If provided with null- Since:
- 4.0.0
-
asSet
@Nonnull java.util.NavigableSet<T> 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 java.lang.Comparable<? super T> & ISnowflake>
- Returns:
- Immutable set of cached elements
-
streamUnordered
@Nonnull java.util.stream.Stream<T> streamUnordered()
Behavior similar toCacheView.stream()
which does not preserve order.- Returns:
- Stream of the contained elements
- Since:
- 4.0.0
-
parallelStreamUnordered
@Nonnull java.util.stream.Stream<T> parallelStreamUnordered()
Behavior similar toCacheView.parallelStream()
which does not preserve order.- Returns:
- (Parallel) Stream of contained elements
- Since:
- 4.0.0
-
-