Class AbstractTuple

java.lang.Object
tools.refinery.interpreter.matchers.tuple.AbstractTuple
All Implemented Interfaces:
ITuple
Direct Known Subclasses:
Tuple, VolatileTuple

public abstract class AbstractTuple extends Object implements ITuple
Common implementation methods for immutable and volatile tuples. The class should not be used directly in client code, except for the definition of new tuple implementations.
Since:
1.7
  • Constructor Details

    • AbstractTuple

      public AbstractTuple()
  • Method Details

    • getElements

      public Object[] getElements()
      As the tuple is supposed to be immutable, do not modify the returned array.
      Specified by:
      getElements in interface ITuple
      Returns:
      the array containing all elements of this Tuple
    • getDistinctElements

      public <T> Set<T> getDistinctElements()
      Specified by:
      getDistinctElements in interface ITuple
      Returns:
      the set containing all distinct elements of this Tuple, cast as type T
    • invertIndex

      public Map<Object,Integer> invertIndex()
      Calculates an inverted index of the elements of this pattern. For each element, the index of the (last) occurrence is calculated.
      Specified by:
      invertIndex in interface ITuple
      Returns:
      the inverted index mapping each element of this pattern to its index in the array
    • invertIndexWithMupliplicity

      public Map<Object,List<Integer>> invertIndexWithMupliplicity()
      Calculates an inverted index of the elements of this pattern. For each element, the index of all of its occurrences is calculated.
      Specified by:
      invertIndexWithMupliplicity in interface ITuple
      Returns:
      the inverted index mapping each element of this pattern to its index in the array
    • raiseIndexingError

      protected IndexOutOfBoundsException raiseIndexingError(int index)
      Since:
      1.7
    • internalEquals

      protected boolean internalEquals(ITuple other)
      Compares the elements stored in this tuple to another tuple
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • doCalcHash

      protected int doCalcHash()
      Since:
      1.7