diff options
author | 2021-08-10 19:18:36 +0200 | |
---|---|---|
committer | 2021-08-10 19:18:36 +0200 | |
commit | daceb22ba196de524928e37a7a9af9cd79ffed63 (patch) | |
tree | 377d94aebc1954d1d9d4d73c120986913d7db428 /model-data | |
parent | Model and model store interfaces and implementations (diff) | |
download | refinery-daceb22ba196de524928e37a7a9af9cd79ffed63.tar.gz refinery-daceb22ba196de524928e37a7a9af9cd79ffed63.tar.zst refinery-daceb22ba196de524928e37a7a9af9cd79ffed63.zip |
getCursor renamed to getAll
Diffstat (limited to 'model-data')
6 files changed, 20 insertions, 18 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMap.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMap.java index fb42d822..2f2cb7a2 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMap.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMap.java | |||
@@ -1,11 +1,13 @@ | |||
1 | package org.eclipse.viatra.solver.data.map; | 1 | package org.eclipse.viatra.solver.data.map; |
2 | 2 | ||
3 | public interface VersionedMap<K,V> extends Versioned{ | 3 | public interface VersionedMap<K,V> extends Versioned{ |
4 | public void put(K key, V value); | ||
5 | public V get(K key); | 4 | public V get(K key); |
5 | public Cursor<K,V> getAll(); | ||
6 | |||
7 | public void put(K key, V value); | ||
8 | public void putAll(Cursor<K,V> cursor); | ||
9 | |||
6 | public long getSize(); | 10 | public long getSize(); |
7 | 11 | ||
8 | public Cursor<K,V> getCursor(); | ||
9 | public DiffCursor<K,V> getDiffCursor(long state); | 12 | public DiffCursor<K,V> getDiffCursor(long state); |
10 | public void putAll(Cursor<K,V> cursor); | ||
11 | } | 13 | } |
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 9ee4cfdf..4f3d8b10 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 | |||
@@ -127,8 +127,8 @@ public class VersionedMapStoreImpl<K, V> implements VersionedMapStore<K, V> { | |||
127 | public DiffCursor<K, V> getDiffCursor(long fromState, long toState) { | 127 | public DiffCursor<K, V> getDiffCursor(long fromState, long toState) { |
128 | VersionedMap<K, V> map1 = createMap(fromState); | 128 | VersionedMap<K, V> map1 = createMap(fromState); |
129 | VersionedMap<K, V> map2 = createMap(toState); | 129 | VersionedMap<K, V> map2 = createMap(toState); |
130 | Cursor<K, V> cursor1 = map1.getCursor(); | 130 | Cursor<K, V> cursor1 = map1.getAll(); |
131 | Cursor<K, V> cursor2 = map2.getCursor(); | 131 | Cursor<K, V> cursor2 = map2.getAll(); |
132 | return new MapDiffCursor<>(this.hashProvider, this.defaultValue, cursor1, cursor2); | 132 | return new MapDiffCursor<>(this.hashProvider, this.defaultValue, cursor1, cursor2); |
133 | } | 133 | } |
134 | } | 134 | } |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/VersionedMapImpl.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/VersionedMapImpl.java index 25473fd8..ef962f13 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/VersionedMapImpl.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/VersionedMapImpl.java | |||
@@ -99,14 +99,14 @@ public class VersionedMapImpl<K,V> implements VersionedMap<K,V>{ | |||
99 | } | 99 | } |
100 | 100 | ||
101 | @Override | 101 | @Override |
102 | public Cursor<K, V> getCursor() { | 102 | public Cursor<K, V> getAll() { |
103 | return new MapCursor<>(this.root,this); | 103 | return new MapCursor<>(this.root,this); |
104 | } | 104 | } |
105 | @Override | 105 | @Override |
106 | public DiffCursor<K, V> getDiffCursor(long toVersion) { | 106 | public DiffCursor<K, V> getDiffCursor(long toVersion) { |
107 | Cursor<K, V> fromCursor = this.getCursor(); | 107 | Cursor<K, V> fromCursor = this.getAll(); |
108 | VersionedMap<K, V> toMap = this.store.createMap(toVersion); | 108 | VersionedMap<K, V> toMap = this.store.createMap(toVersion); |
109 | Cursor<K, V> toCursor = toMap.getCursor(); | 109 | Cursor<K, V> toCursor = toMap.getAll(); |
110 | return new MapDiffCursor<>(this.hashProvider,this.defaultValue, fromCursor, toCursor); | 110 | return new MapDiffCursor<>(this.hashProvider,this.defaultValue, fromCursor, toCursor); |
111 | 111 | ||
112 | } | 112 | } |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/internal/ModelImpl.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/internal/ModelImpl.java index 49699933..55ddfd3a 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/internal/ModelImpl.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/internal/ModelImpl.java | |||
@@ -53,7 +53,7 @@ public class ModelImpl implements Model { | |||
53 | 53 | ||
54 | @Override | 54 | @Override |
55 | public <K, V> Cursor<K, V> getAll(DataRepresentation<K, V> representation) { | 55 | public <K, V> Cursor<K, V> getAll(DataRepresentation<K, V> representation) { |
56 | return getMap(representation).getCursor(); | 56 | return getMap(representation).getAll(); |
57 | } | 57 | } |
58 | 58 | ||
59 | @Override | 59 | @Override |
@@ -84,7 +84,7 @@ public class ModelImpl implements Model { | |||
84 | 84 | ||
85 | private <K, V> MapDiffCursor<K, V> constructDiffCursor(Model toModel, DataRepresentation<K, V> representation) { | 85 | private <K, V> MapDiffCursor<K, V> constructDiffCursor(Model toModel, DataRepresentation<K, V> representation) { |
86 | @SuppressWarnings("unchecked") | 86 | @SuppressWarnings("unchecked") |
87 | Cursor<K, V> fromCursor = (Cursor<K, V>) this.maps.get(representation).getCursor(); | 87 | Cursor<K, V> fromCursor = (Cursor<K, V>) this.maps.get(representation).getAll(); |
88 | Cursor<K, V> toCursor = toModel.getAll(representation); | 88 | Cursor<K, V> toCursor = toModel.getAll(representation); |
89 | 89 | ||
90 | ContinousHashProvider<K> hashProvider = representation.getHashProvider(); | 90 | ContinousHashProvider<K> hashProvider = representation.getHashProvider(); |
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/fuzz/ContentEqualsFuzzTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/fuzz/ContentEqualsFuzzTest.java index f7d3d548..5004c152 100644 --- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/fuzz/ContentEqualsFuzzTest.java +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/fuzz/ContentEqualsFuzzTest.java | |||
@@ -59,7 +59,7 @@ class ContentEqualsFuzzTest { | |||
59 | 59 | ||
60 | // Get the content of the first map | 60 | // Get the content of the first map |
61 | List<SimpleEntry<Integer, String>> content = new LinkedList<>(); | 61 | List<SimpleEntry<Integer, String>> content = new LinkedList<>(); |
62 | Cursor<Integer, String> cursor = sut1.getCursor(); | 62 | Cursor<Integer, String> cursor = sut1.getAll(); |
63 | while (cursor.move()) { | 63 | while (cursor.move()) { |
64 | content.add(new SimpleEntry<>(cursor.getKey(), cursor.getValue())); | 64 | content.add(new SimpleEntry<>(cursor.getKey(), cursor.getValue())); |
65 | } | 65 | } |
@@ -88,8 +88,8 @@ class ContentEqualsFuzzTest { | |||
88 | 88 | ||
89 | 89 | ||
90 | // By cursors | 90 | // By cursors |
91 | Cursor<Integer, String> cursor1 = sut1.getCursor(); | 91 | Cursor<Integer, String> cursor1 = sut1.getAll(); |
92 | Cursor<Integer, String> cursor2 = sut2.getCursor(); | 92 | Cursor<Integer, String> cursor2 = sut2.getAll(); |
93 | int index3 = 1; | 93 | int index3 = 1; |
94 | boolean canMove = true; | 94 | boolean canMove = true; |
95 | do{ | 95 | do{ |
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/utils/MapTestEnvironment.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/utils/MapTestEnvironment.java index 3f276481..aaf9f50c 100644 --- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/utils/MapTestEnvironment.java +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/utils/MapTestEnvironment.java | |||
@@ -63,8 +63,8 @@ public class MapTestEnvironment<K, V> { | |||
63 | public static <K, V> void compareTwoMaps(String title, VersionedMapImpl<K, V> map1, | 63 | public static <K, V> void compareTwoMaps(String title, VersionedMapImpl<K, V> map1, |
64 | VersionedMapImpl<K, V> map2, List<Throwable> errors) { | 64 | VersionedMapImpl<K, V> map2, List<Throwable> errors) { |
65 | // 1. Comparing cursors. | 65 | // 1. Comparing cursors. |
66 | Cursor<K, V> cursor1 = map1.getCursor(); | 66 | Cursor<K, V> cursor1 = map1.getAll(); |
67 | Cursor<K, V> cursor2 = map2.getCursor(); | 67 | Cursor<K, V> cursor2 = map2.getAll(); |
68 | while (!cursor1.isTerminated()) { | 68 | while (!cursor1.isTerminated()) { |
69 | if (cursor2.isTerminated()) { | 69 | if (cursor2.isTerminated()) { |
70 | fail("cursor 2 terminated before cursor1"); | 70 | fail("cursor 2 terminated before cursor1"); |
@@ -136,7 +136,7 @@ public class MapTestEnvironment<K, V> { | |||
136 | // <key,value> pair. | 136 | // <key,value> pair. |
137 | // Tests iterators | 137 | // Tests iterators |
138 | int elementsInSutEntrySet = 0; | 138 | int elementsInSutEntrySet = 0; |
139 | Cursor<K, V> cursor = sut.getCursor(); | 139 | Cursor<K, V> cursor = sut.getAll(); |
140 | while (cursor.move()) { | 140 | while (cursor.move()) { |
141 | elementsInSutEntrySet++; | 141 | elementsInSutEntrySet++; |
142 | K key = cursor.getKey(); | 142 | K key = cursor.getKey(); |
@@ -164,7 +164,7 @@ public class MapTestEnvironment<K, V> { | |||
164 | 164 | ||
165 | public static <K,V> void checkOrder(String scenario, VersionedMap<K,V> versionedMap) { | 165 | public static <K,V> void checkOrder(String scenario, VersionedMap<K,V> versionedMap) { |
166 | K previous = null; | 166 | K previous = null; |
167 | Cursor<K, V> cursor = versionedMap.getCursor(); | 167 | Cursor<K, V> cursor = versionedMap.getAll(); |
168 | while(cursor.move()) { | 168 | while(cursor.move()) { |
169 | System.out.println(cursor.getKey() + " " + ((VersionedMapImpl<K, V>) versionedMap).getHashProvider().getHash(cursor.getKey(), 0)); | 169 | System.out.println(cursor.getKey() + " " + ((VersionedMapImpl<K, V>) versionedMap).getHashProvider().getHash(cursor.getKey(), 0)); |
170 | if(previous != null) { | 170 | if(previous != null) { |
@@ -178,7 +178,7 @@ public class MapTestEnvironment<K, V> { | |||
178 | 178 | ||
179 | public void printComparison() { | 179 | public void printComparison() { |
180 | System.out.println("SUT:"); | 180 | System.out.println("SUT:"); |
181 | printEntrySet(sut.getCursor()); | 181 | printEntrySet(sut.getAll()); |
182 | System.out.println("Oracle:"); | 182 | System.out.println("Oracle:"); |
183 | printEntrySet(oracle.entrySet().iterator()); | 183 | printEntrySet(oracle.entrySet().iterator()); |
184 | } | 184 | } |