public interface IMemoryView<T>
extends java.lang.Iterable<T>
See IMemory
.
Implementors must provide semantic (not identity-based) hashCode() and equals() using the static helpers hashCode(IMemoryView)
and equals(IMemoryView, Object)
here.
Modifier and Type | Method and Description |
---|---|
default java.util.Map<T,java.lang.Integer> |
asMap()
For compatibility with legacy code relying on element-to-integer maps.
|
default java.util.stream.Stream<T> |
asStream() |
boolean |
containsNonZero(T value) |
boolean |
containsNonZeroUnsafe(java.lang.Object value) |
java.util.Set<T> |
distinctValues()
The set of distinct values
|
default java.lang.Iterable<java.util.Map.Entry<T,java.lang.Integer>> |
entriesWithMultiplicities() |
static <T> boolean |
equals(IMemoryView<T> self,
java.lang.Object obj)
Provides semantic equality comparison.
|
default void |
forEachEntryWithMultiplicities(java.util.function.BiConsumer<T,java.lang.Integer> entryConsumer)
Process contained values with their multiplicities
|
static <T> IMemoryView<T> |
fromMap(java.util.Map<T,java.lang.Integer> wrapped)
For compatibility with legacy code relying on element-to-integer maps.
|
int |
getCount(T value)
Returns the number of occurrences of the given value.
|
int |
getCountUnsafe(java.lang.Object value)
Returns the number of occurrences of the given value (which may be of any type).
|
static <T> int |
hashCode(IMemoryView<T> memory)
Provides semantic hashCode() comparison.
|
boolean |
isEmpty() |
int |
size() |
default T |
theContainedVersionOf(T value)
Where supported, returns the stored element that is equal to the given value, or null if none.
|
default T |
theContainedVersionOfUnsafe(java.lang.Object value)
Where supported, returns the stored element that is equal to the given value (of any type),
or null if none.
|
int getCount(T value)
int getCountUnsafe(java.lang.Object value)
boolean containsNonZero(T value)
boolean containsNonZeroUnsafe(java.lang.Object value)
int size()
boolean isEmpty()
java.util.Set<T> distinctValues()
default T theContainedVersionOf(T value)
For collections that do not support canonicalization, simply returns the argument if contained, null if none.
default T theContainedVersionOfUnsafe(java.lang.Object value)
For collections that do not support canonicalization, simply returns the argument if contained, null if none.
default java.lang.Iterable<java.util.Map.Entry<T,java.lang.Integer>> entriesWithMultiplicities()
default void forEachEntryWithMultiplicities(java.util.function.BiConsumer<T,java.lang.Integer> entryConsumer)
default java.util.Map<T,java.lang.Integer> asMap()
static <T> IMemoryView<T> fromMap(java.util.Map<T,java.lang.Integer> wrapped)
default java.util.stream.Stream<T> asStream()
static <T> boolean equals(IMemoryView<T> self, java.lang.Object obj)
static <T> int hashCode(IMemoryView<T> memory)