diff options
Diffstat (limited to 'subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/memories/AbstractTrivialMaskedMemory.java')
-rw-r--r-- | subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/memories/AbstractTrivialMaskedMemory.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/memories/AbstractTrivialMaskedMemory.java b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/memories/AbstractTrivialMaskedMemory.java new file mode 100644 index 00000000..66587f77 --- /dev/null +++ b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/memories/AbstractTrivialMaskedMemory.java | |||
@@ -0,0 +1,58 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2018, Gabor Bergmann, IncQuery Labs Ltd. | ||
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 | package tools.refinery.viatra.runtime.matchers.memories; | ||
10 | |||
11 | import java.util.Iterator; | ||
12 | import java.util.Map; | ||
13 | |||
14 | import tools.refinery.viatra.runtime.matchers.tuple.ITuple; | ||
15 | import tools.refinery.viatra.runtime.matchers.tuple.Tuple; | ||
16 | import tools.refinery.viatra.runtime.matchers.tuple.TupleMask; | ||
17 | import tools.refinery.viatra.runtime.matchers.util.CollectionsFactory; | ||
18 | import tools.refinery.viatra.runtime.matchers.util.CollectionsFactory.MemoryType; | ||
19 | import tools.refinery.viatra.runtime.matchers.util.timeline.Timeline; | ||
20 | import tools.refinery.viatra.runtime.matchers.util.IMemory; | ||
21 | |||
22 | /** | ||
23 | * Common parts of nullary and identity specializations. | ||
24 | * | ||
25 | * @noextend This class is not intended to be subclassed by clients. | ||
26 | * @author Gabor Bergmann | ||
27 | * @since 2.0 | ||
28 | */ | ||
29 | abstract class AbstractTrivialMaskedMemory<Timestamp extends Comparable<Timestamp>> extends MaskedTupleMemory<Timestamp> { | ||
30 | |||
31 | protected IMemory<Tuple> tuples; | ||
32 | |||
33 | protected AbstractTrivialMaskedMemory(TupleMask mask, MemoryType bucketType, Object owner) { | ||
34 | super(mask, owner); | ||
35 | tuples = CollectionsFactory.createMemory(Object.class, bucketType); | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public Map<Tuple, Timeline<Timestamp>> getWithTimeline(ITuple signature) { | ||
40 | throw new UnsupportedOperationException("Timeless memories do not support timestamp-based lookup!"); | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public void clear() { | ||
45 | tuples.clear(); | ||
46 | } | ||
47 | |||
48 | @Override | ||
49 | public int getTotalSize() { | ||
50 | return tuples.size(); | ||
51 | } | ||
52 | |||
53 | @Override | ||
54 | public Iterator<Tuple> iterator() { | ||
55 | return tuples.iterator(); | ||
56 | } | ||
57 | |||
58 | } | ||