Class MapBackedMemoryView<T>
- java.lang.Object
-
- org.eclipse.viatra.query.runtime.matchers.util.MapBackedMemoryView<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>,IMemoryView<T>
public class MapBackedMemoryView<T> extends java.lang.Object implements IMemoryView<T>
Wraps a Map(mapping elements to non-zero multiplicities) into an IMemoryView.- Since:
- 2.0
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMapBackedMemoryView(java.util.Map<T,java.lang.Integer> wrapped)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsNonZero(T value)booleancontainsNonZeroUnsafe(java.lang.Object value)java.util.Set<T>distinctValues()The set of distinct valuesjava.lang.Iterable<java.util.Map.Entry<T,java.lang.Integer>>entriesWithMultiplicities()booleanequals(java.lang.Object obj)voidforEachEntryWithMultiplicities(java.util.function.BiConsumer<T,java.lang.Integer> entryConsumer)Process contained values with their multiplicitiesintgetCount(T value)Returns the number of occurrences of the given value.intgetCountUnsafe(java.lang.Object value)Returns the number of occurrences of the given value (which may be of any type).inthashCode()booleanisEmpty()java.util.Iterator<T>iterator()intsize()java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.viatra.query.runtime.matchers.util.IMemoryView
asMap, asStream, theContainedVersionOf, theContainedVersionOfUnsafe
-
-
-
-
Constructor Detail
-
MapBackedMemoryView
protected MapBackedMemoryView(java.util.Map<T,java.lang.Integer> wrapped)
- Parameters:
wrapped- an equivalent map from contained objects to multiplicities
-
-
Method Detail
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<T>
-
getCount
public int getCount(T value)
Description copied from interface:IMemoryViewReturns the number of occurrences of the given value.- Specified by:
getCountin interfaceIMemoryView<T>- Returns:
- the number of occurrences
-
getCountUnsafe
public int getCountUnsafe(java.lang.Object value)
Description copied from interface:IMemoryViewReturns the number of occurrences of the given value (which may be of any type).- Specified by:
getCountUnsafein interfaceIMemoryView<T>- Returns:
- the number of occurrences
-
containsNonZero
public boolean containsNonZero(T value)
- Specified by:
containsNonZeroin interfaceIMemoryView<T>- Returns:
- true if the given value is contained with a nonzero multiplicity
-
containsNonZeroUnsafe
public boolean containsNonZeroUnsafe(java.lang.Object value)
- Specified by:
containsNonZeroUnsafein interfaceIMemoryView<T>- Returns:
- true if the given value (which may be of any type) is contained with a nonzero multiplicity
-
size
public int size()
- Specified by:
sizein interfaceIMemoryView<T>- Returns:
- the number of distinct values
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceIMemoryView<T>- Returns:
- iff contains at least one value with non-zero occurrences
-
distinctValues
public java.util.Set<T> distinctValues()
Description copied from interface:IMemoryViewThe set of distinct values- Specified by:
distinctValuesin interfaceIMemoryView<T>
-
forEachEntryWithMultiplicities
public void forEachEntryWithMultiplicities(java.util.function.BiConsumer<T,java.lang.Integer> entryConsumer)
Description copied from interface:IMemoryViewProcess contained values with their multiplicities- Specified by:
forEachEntryWithMultiplicitiesin interfaceIMemoryView<T>
-
entriesWithMultiplicities
public java.lang.Iterable<java.util.Map.Entry<T,java.lang.Integer>> entriesWithMultiplicities()
- Specified by:
entriesWithMultiplicitiesin interfaceIMemoryView<T>- Returns:
- an unmodifiable view of contained values with their multiplicities
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-