diff options
Diffstat (limited to 'subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/EqualityFilterNode.java')
-rw-r--r-- | subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/EqualityFilterNode.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/EqualityFilterNode.java b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/EqualityFilterNode.java new file mode 100644 index 00000000..014c2016 --- /dev/null +++ b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/single/EqualityFilterNode.java | |||
@@ -0,0 +1,41 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2004-2008 Gabor Bergmann and Daniel Varro | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | |||
10 | package tools.refinery.viatra.runtime.rete.single; | ||
11 | |||
12 | import tools.refinery.viatra.runtime.matchers.tuple.Tuple; | ||
13 | import tools.refinery.viatra.runtime.rete.network.ReteContainer; | ||
14 | |||
15 | public class EqualityFilterNode extends FilterNode { | ||
16 | |||
17 | int[] indices; | ||
18 | int first; | ||
19 | |||
20 | /** | ||
21 | * @param reteContainer | ||
22 | * @param indices | ||
23 | * indices of the Tuple that should hold equal values | ||
24 | */ | ||
25 | public EqualityFilterNode(ReteContainer reteContainer, int[] indices) { | ||
26 | super(reteContainer); | ||
27 | this.indices = indices; | ||
28 | first = indices[0]; | ||
29 | } | ||
30 | |||
31 | @Override | ||
32 | public boolean check(Tuple ps) { | ||
33 | Object firstElement = ps.get(first); | ||
34 | for (int i = 1 /* first is omitted */; i < indices.length; i++) { | ||
35 | if (!ps.get(indices[i]).equals(firstElement)) | ||
36 | return false; | ||
37 | } | ||
38 | return true; | ||
39 | } | ||
40 | |||
41 | } | ||