Class SingletonMemoryView<Value>

java.lang.Object
tools.refinery.interpreter.matchers.util.SingletonMemoryView<Value>
All Implemented Interfaces:
Iterable<Value>, IMemoryView<Value>

public final class SingletonMemoryView<Value> extends Object implements IMemoryView<Value>
An immutable memory view that consists of a single non-null element with multiplicity 1.
Since:
2.0
  • Constructor Details

    • SingletonMemoryView

      public SingletonMemoryView(Value value)
  • Method Details

    • iterator

      public Iterator<Value> iterator()
      Specified by:
      iterator in interface Iterable<Value>
    • getCount

      public int getCount(Value value)
      Description copied from interface: IMemoryView
      Returns the number of occurrences of the given value.
      Specified by:
      getCount in interface IMemoryView<Value>
      Returns:
      the number of occurrences
    • getCountUnsafe

      public int getCountUnsafe(Object value)
      Description copied from interface: IMemoryView
      Returns the number of occurrences of the given value (which may be of any type).
      Specified by:
      getCountUnsafe in interface IMemoryView<Value>
      Returns:
      the number of occurrences
    • containsNonZero

      public boolean containsNonZero(Value value)
      Specified by:
      containsNonZero in interface IMemoryView<Value>
      Returns:
      true if the given value is contained with a nonzero multiplicity
    • containsNonZeroUnsafe

      public boolean containsNonZeroUnsafe(Object value)
      Specified by:
      containsNonZeroUnsafe in interface IMemoryView<Value>
      Returns:
      true if the given value (which may be of any type) is contained with a nonzero multiplicity
    • size

      public int size()
      Specified by:
      size in interface IMemoryView<Value>
      Returns:
      the number of distinct values
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface IMemoryView<Value>
      Returns:
      iff contains at least one value with non-zero occurrences
    • distinctValues

      public Set<Value> distinctValues()
      Description copied from interface: IMemoryView
      The set of distinct values
      Specified by:
      distinctValues in interface IMemoryView<Value>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object