Interface IMemoryView<T>
- All Superinterfaces:
Iterable<T>
- All Known Subinterfaces:
IDeltaBag<T>
,IMemory<T>
,IMultiset<T>
,ISetMemory<T>
,MarkedMemory<Value>
,MarkedMemory.MarkedDeltaBag<Value>
,MarkedMemory.MarkedMultiset<Value>
,MarkedMemory.MarkedSet<Value>
- All Known Implementing Classes:
EclipseCollectionsBagMemory
,EclipseCollectionsDeltaBag
,EclipseCollectionsLongMultiset
,EclipseCollectionsLongSetMemory
,EclipseCollectionsMultiset
,EclipseCollectionsSetMemory
,EmptyMemory
,MapBackedMemoryView
,SingletonMemoryView
A read-only view on a memory containing a positive or negative number of equal() copies for some values.
During iterations, each distinct value is iterated only once.
See IMemory
.
Implementors must provide semantic (not identity-based) hashCode() and equals() using the static helpers hashCode(IMemoryView)
and equals(IMemoryView, Object)
here.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionasMap()
For compatibility with legacy code relying on element-to-integer maps.asStream()
boolean
containsNonZero
(T value) boolean
containsNonZeroUnsafe
(Object value) The set of distinct valuesstatic <T> boolean
equals
(IMemoryView<T> self, Object obj) Provides semantic equality comparison.default void
forEachEntryWithMultiplicities
(BiConsumer<T, Integer> entryConsumer) Process contained values with their multiplicitiesstatic <T> IMemoryView
<T> For compatibility with legacy code relying on element-to-integer maps.int
Returns the number of occurrences of the given value.int
getCountUnsafe
(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
Where supported, returns the stored element that is equal to the given value (of any type), or null if none.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
getCount
Returns the number of occurrences of the given value.- Returns:
- the number of occurrences
-
getCountUnsafe
Returns the number of occurrences of the given value (which may be of any type).- Returns:
- the number of occurrences
-
containsNonZero
- Returns:
- true if the given value is contained with a nonzero multiplicity
-
containsNonZeroUnsafe
- Returns:
- true if the given value (which may be of any type) is contained with a nonzero multiplicity
-
size
int size()- Returns:
- the number of distinct values
-
isEmpty
boolean isEmpty()- Returns:
- iff contains at least one value with non-zero occurrences
-
distinctValues
The set of distinct values -
theContainedVersionOf
Where supported, returns the stored element that is equal to the given value, or null if none. Useful for canonicalization in case of non-identity equals().For collections that do not support canonicalization, simply returns the argument if contained, null if none.
- Returns:
- a value equal to the argument if such a value is stored, or null if none
-
theContainedVersionOfUnsafe
Where supported, returns the stored element that is equal to the given value (of any type), or null if none. Useful for canonicalization in case of non-identity equals().For collections that do not support canonicalization, simply returns the argument if contained, null if none.
- Returns:
- a value equal to the argument if such a value is stored, or null if none
-
entriesWithMultiplicities
- Returns:
- an unmodifiable view of contained values with their multiplicities
-
forEachEntryWithMultiplicities
Process contained values with their multiplicities -
asMap
For compatibility with legacy code relying on element-to-integer maps.- Returns:
- an unmodifiable view of contained values with their multiplicities
-
fromMap
For compatibility with legacy code relying on element-to-integer maps.- Returns:
- an unmodifiable view of contained values with their multiplicities
-
asStream
- Returns:
- a stream of values, iterable once
- Since:
- 2.1
-
equals
Provides semantic equality comparison. -
hashCode
Provides semantic hashCode() comparison.
-