diff options
author | 2021-08-05 12:54:28 +0200 | |
---|---|---|
committer | 2021-08-05 12:54:28 +0200 | |
commit | 2627755cc10651f2b815980149c96bda54889d94 (patch) | |
tree | b846eb440f55416ab89780ea2d30db861de51f2f | |
parent | Exception removed from interface. (diff) | |
download | refinery-2627755cc10651f2b815980149c96bda54889d94.tar.gz refinery-2627755cc10651f2b815980149c96bda54889d94.tar.zst refinery-2627755cc10651f2b815980149c96bda54889d94.zip |
getStates moved to interface level
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStore.java | 4 | ||||
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStore.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStore.java index 60d869ec..0ff0773f 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStore.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStore.java | |||
@@ -1,10 +1,14 @@ | |||
1 | package org.eclipse.viatra.solver.data.map; | 1 | package org.eclipse.viatra.solver.data.map; |
2 | 2 | ||
3 | import java.util.Set; | ||
4 | |||
3 | public interface VersionedMapStore<K, V> { | 5 | public interface VersionedMapStore<K, V> { |
4 | 6 | ||
5 | public VersionedMap<K, V> createMap(); | 7 | public VersionedMap<K, V> createMap(); |
6 | 8 | ||
7 | public VersionedMap<K, V> createMap(long state); | 9 | public VersionedMap<K, V> createMap(long state); |
10 | |||
11 | public Set<Long> getStates(); | ||
8 | 12 | ||
9 | public DiffCursor<K,V> getDiffCursor(long fromState, long toState); | 13 | public DiffCursor<K,V> getDiffCursor(long fromState, long toState); |
10 | } \ No newline at end of file | 14 | } \ No newline at end of file |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java index ab55e4bc..9ee4cfdf 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java | |||
@@ -76,8 +76,9 @@ public class VersionedMapStoreImpl<K, V> implements VersionedMapStore<K, V> { | |||
76 | ContinousHashProvider<K> hashProvider, V defaultValue) { | 76 | ContinousHashProvider<K> hashProvider, V defaultValue) { |
77 | return createSharedVersionedMapStores(amount, hashProvider, defaultValue, new VersionedMapStoreConfiguration()); | 77 | return createSharedVersionedMapStores(amount, hashProvider, defaultValue, new VersionedMapStoreConfiguration()); |
78 | } | 78 | } |
79 | 79 | ||
80 | synchronized Set<Long> getStates() { | 80 | @Override |
81 | public synchronized Set<Long> getStates() { | ||
81 | return states.keySet(); | 82 | return states.keySet(); |
82 | } | 83 | } |
83 | 84 | ||
@@ -91,6 +92,7 @@ public class VersionedMapStoreImpl<K, V> implements VersionedMapStore<K, V> { | |||
91 | ImmutableNode<K, V> data = revert(state); | 92 | ImmutableNode<K, V> data = revert(state); |
92 | return new VersionedMapImpl<>(this, hashProvider, defaultValue, data); | 93 | return new VersionedMapImpl<>(this, hashProvider, defaultValue, data); |
93 | } | 94 | } |
95 | |||
94 | 96 | ||
95 | public synchronized ImmutableNode<K, V> revert(long state) { | 97 | public synchronized ImmutableNode<K, V> revert(long state) { |
96 | if (states.containsKey(state)) { | 98 | if (states.containsKey(state)) { |