org.eclipse.viatra.query.runtime.matchers.tuple

## Class TupleMask

- java.lang.Object
- - org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask

-     public class TupleMask
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int[]` | `indices` indices[i] specifies the index of the substitution in the original tuple that occupies the i-th place in the masked signature.
    `int[]` | `indicesSorted` indicesSorted is indices, sorted in ascending order.
    `int` | `sourceWidth` the size of the tuple this mask is applied to

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TupleMask(boolean[] keep)` Creates a TupleMask instance that discards positions where keep is true
    `TupleMask(int[] indices, int sourceWidth)` Creates a TupleMask instance with the given indices array

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static TupleMask` | `append(TupleMask left, TupleMask right)` Creates a TupleMask instance that selects whatever is selected by left, and appends whatever is selected by right.
    `Tuple` | `combine(Tuple unmasked, Tuple masked, boolean useInheritance, boolean asComplementer)` Combines two substitutions.
    `static TupleMask` | `displace(int from, int to, int sourceWidth)` Creates a TupleMask instance that moves an element from one index to other, shifting the others if neccessary.
    `static TupleMask` | `empty(int sourceWidth)` Creates a TupleMask instance of the given size that does not emit output.
    `boolean` | `equals(java.lang.Object obj)`
    `int` | `hashCode()`
    `static TupleMask` | `identity(int size)` Creates a TupleMask instance of the given size that maps every single element intact
    `static TupleMask` | `linear(int size, int sourceWidth)` Creates a TupleMask instance of the given size that maps the first 'size' elements intact
    `static TupleMask` | `omit(int omission, int sourceWidth)` Creates a TupleMask instance that maps the tuple intact save for a single element at the specified index which is omitted
    `static TupleMask` | `selectSingle(int selected, int sourceWidth)` Creates a TupleMask instance that selects a single element of the tuple.
    `void` | `sort()` Generates indicesSorted from indices
    `java.lang.String` | `toString()`
    `<T> java.util.List<T>` | `transform(java.util.List<T> original)` Generates a masked view of the original tuple.
    `Tuple` | `transform(Tuple original)` Generates a masked view of the original tuple.
    `TupleMask` | `transform(TupleMask mask)` Transforms a given mask directly, instead of transforming tuples that were transformed by the other mask.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### indices

          public final int[] indices

      indices[i] specifies the index of the substitution in the original tuple that occupies the i-th place in the masked signature.

    - #### indicesSorted

          public int[] indicesSorted

      indicesSorted is indices, sorted in ascending order.

    - #### sourceWidth

          public int sourceWidth

      the size of the tuple this mask is applied to

  - ### Constructor Detail

    - #### TupleMask

          public TupleMask(int[] indices,
                           int sourceWidth)

      Creates a TupleMask instance with the given indices array

    - #### TupleMask

          public TupleMask(boolean[] keep)

      Creates a TupleMask instance that discards positions where keep is true

  - ### Method Detail

    - #### linear

          public static TupleMask linear(int size,
                                         int sourceWidth)

      Creates a TupleMask instance of the given size that maps the first 'size' elements intact

    - #### identity

          public static TupleMask identity(int size)

      Creates a TupleMask instance of the given size that maps every single element intact

    - #### empty

          public static TupleMask empty(int sourceWidth)

      Creates a TupleMask instance of the given size that does not emit output.

    - #### omit

          public static TupleMask omit(int omission,
                                       int sourceWidth)

      Creates a TupleMask instance that maps the tuple intact save for a single element at the specified index which is omitted

    - #### displace

          public static TupleMask displace(int from,
                                           int to,
                                           int sourceWidth)

      Creates a TupleMask instance that moves an element from one index to other, shifting the others if neccessary.

    - #### selectSingle

          public static TupleMask selectSingle(int selected,
                                               int sourceWidth)

      Creates a TupleMask instance that selects a single element of the tuple.

    - #### append

          public static TupleMask append(TupleMask left,
                                         TupleMask right)

      Creates a TupleMask instance that selects whatever is selected by left, and appends whatever is selected by right. PRE: left and right have the same sourcewidth

    - #### sort

          public void sort()

      Generates indicesSorted from indices

    - #### transform

          public Tuple transform(Tuple original)

      Generates a masked view of the original tuple.

    - #### transform

          public <T> java.util.List<T> transform(java.util.List<T> original)

      Generates a masked view of the original tuple.

    - #### transform

          public TupleMask transform(TupleMask mask)

      Transforms a given mask directly, instead of transforming tuples that were transformed by the other mask.
      Returns:
        a mask that cascades the effects this mask after the mask provided as parameter.

    - #### combine

          public Tuple combine(Tuple unmasked,
                               Tuple masked,
                               boolean useInheritance,
                               boolean asComplementer)

      Combines two substitutions. The new pattern will contain all substitutions of masked and unmasked, assuming that the elements of masked indicated by this mask are already matched against unmasked. POST: the result will start with an exact copy of unmasked
      Parameters:
        `unmasked` - primary pattern substitution that is left intact.
        `masked` - secondary pattern substitution that is transformed to the end of the result.
        `useInheritance` - whether to use inheritance or copy umasked into result instead.
        `asComplementer` - whether this mask maps from the masked Tuple to the tail of the result or to the unmasked one.
      Returns:
        new pattern that is a combination of unmasked and masked.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`