blob: 52a83f694d29670d9c5d987be54588bb239d541a (
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
|
package tools.refinery.store.query.viatra.internal.matcher;
import org.eclipse.viatra.query.runtime.rete.index.IterableIndexer;
import tools.refinery.store.map.Cursor;
import tools.refinery.store.tuple.Tuple;
import java.util.Iterator;
class FunctionalCursor<T> implements Cursor<Tuple, T> {
private final IterableIndexer indexer;
private final Iterator<org.eclipse.viatra.query.runtime.matchers.tuple.Tuple> iterator;
private boolean terminated;
private Tuple key;
private T value;
public FunctionalCursor(IterableIndexer indexer) {
this.indexer = indexer;
iterator = indexer.getSignatures().iterator();
}
@Override
public Tuple getKey() {
return key;
}
@Override
public T getValue() {
return value;
}
@Override
public boolean isTerminated() {
return terminated;
}
@Override
public boolean move() {
if (!terminated && iterator.hasNext()) {
var match = iterator.next();
key = MatcherUtils.toRefineryTuple(match);
value = MatcherUtils.getSingleValue(indexer.get(match));
return true;
}
terminated = true;
return false;
}
}
|