aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-matchers/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/ITuple.java
blob: 9201478147568231a86ddefad4c0c1d5014db468 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*******************************************************************************
 * Copyright (c) 2010-2017, Zoltan Ujhelyi, IncQuery Labs Ltd.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-v20.html.
 * 
 * SPDX-License-Identifier: EPL-2.0
 *******************************************************************************/
package tools.refinery.viatra.runtime.matchers.tuple;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Represents both mutable and immutable tuples
 * 
 * @author Zoltan Ujhelyi
 * @since 1.7
 *
 */
public interface ITuple {

    /**
     * @pre: 0 <= index < getSize()
     * 
     * @return the element at the specified index
     */
    Object get(int index);

    /**
     * As the tuple is supposed to be immutable, do not modify the returned array.
     * @return the array containing all elements of this Tuple
     */
    Object[] getElements();

    /**
     * @return the set containing all distinct elements of this Tuple, cast as type T
     */
    <T> Set<T> getDistinctElements();

    /**
     * @return number of elements
     */
    int getSize();
    
    /**
     * Calculates an inverted index of the elements of this pattern. For each element, the index of the (last)
     * occurrence is calculated.
     * 
     * @return the inverted index mapping each element of this pattern to its index in the array
     */
    Map<Object, Integer> invertIndex();

    /**
     * Calculates an inverted index of the elements of this pattern. For each element, the index of all of its
     * occurrences is calculated.
     * 
     * @return the inverted index mapping each element of this pattern to its index in the array
     */
    Map<Object, List<Integer>> invertIndexWithMupliplicity();

    Tuple toImmutable();
}