diff options
Diffstat (limited to 'model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java')
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java index 6c177611..a18d540d 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java | |||
@@ -8,25 +8,25 @@ import java.util.List; | |||
8 | import org.eclipse.viatra.solver.data.map.Cursor; | 8 | import org.eclipse.viatra.solver.data.map.Cursor; |
9 | import org.eclipse.viatra.solver.data.map.VersionedMap; | 9 | import org.eclipse.viatra.solver.data.map.VersionedMap; |
10 | 10 | ||
11 | public class MapCursor<KEY,VALUE> implements Cursor<KEY,VALUE> { | 11 | public class MapCursor<K,V> implements Cursor<K,V> { |
12 | // Constants | 12 | // Constants |
13 | static int IndexStart = -1; | 13 | static int IndexStart = -1; |
14 | static int IndexFinish = -2; | 14 | static int IndexFinish = -2; |
15 | 15 | ||
16 | // Tree stack | 16 | // Tree stack |
17 | ArrayDeque<Node<KEY,VALUE>> nodeStack; | 17 | ArrayDeque<Node<K,V>> nodeStack; |
18 | ArrayDeque<Integer> nodeIndexStack; | 18 | ArrayDeque<Integer> nodeIndexStack; |
19 | int dataIndex; | 19 | int dataIndex; |
20 | 20 | ||
21 | // Values | 21 | // Values |
22 | KEY key; | 22 | K key; |
23 | VALUE value; | 23 | V value; |
24 | 24 | ||
25 | // Hash code for checking concurrent modifications | 25 | // Hash code for checking concurrent modifications |
26 | final VersionedMap<KEY,VALUE> map; | 26 | final VersionedMap<K,V> map; |
27 | final int creationHash; | 27 | final int creationHash; |
28 | 28 | ||
29 | public MapCursor(Node<KEY, VALUE> root, VersionedMap<KEY,VALUE> map) { | 29 | public MapCursor(Node<K, V> root, VersionedMap<K,V> map) { |
30 | // Initializing tree stack | 30 | // Initializing tree stack |
31 | super(); | 31 | super(); |
32 | this.nodeStack = new ArrayDeque<>(); | 32 | this.nodeStack = new ArrayDeque<>(); |
@@ -47,11 +47,11 @@ public class MapCursor<KEY,VALUE> implements Cursor<KEY,VALUE> { | |||
47 | this.creationHash = map.hashCode(); | 47 | this.creationHash = map.hashCode(); |
48 | } | 48 | } |
49 | 49 | ||
50 | public KEY getKey() { | 50 | public K getKey() { |
51 | return key; | 51 | return key; |
52 | } | 52 | } |
53 | 53 | ||
54 | public VALUE getValue() { | 54 | public V getValue() { |
55 | return value; | 55 | return value; |
56 | } | 56 | } |
57 | 57 | ||
@@ -83,13 +83,13 @@ public class MapCursor<KEY,VALUE> implements Cursor<KEY,VALUE> { | |||
83 | return this.map.hashCode() != this.creationHash; | 83 | return this.map.hashCode() != this.creationHash; |
84 | } | 84 | } |
85 | @Override | 85 | @Override |
86 | public List<VersionedMap<KEY, VALUE>> getDependingMaps() { | 86 | public List<VersionedMap<K, V>> getDependingMaps() { |
87 | return List.of(this.map); | 87 | return List.of(this.map); |
88 | } | 88 | } |
89 | 89 | ||
90 | public static <KEY,VALUE> boolean sameSubnode(MapCursor<KEY,VALUE> cursor1, MapCursor<KEY,VALUE> cursor2) { | 90 | public static <K,V> boolean sameSubnode(MapCursor<K,V> cursor1, MapCursor<K,V> cursor2) { |
91 | Node<KEY, VALUE> nodeOfCursor1 = cursor1.nodeStack.peek(); | 91 | Node<K, V> nodeOfCursor1 = cursor1.nodeStack.peek(); |
92 | Node<KEY, VALUE> nodeOfCursor2 = cursor2.nodeStack.peek(); | 92 | Node<K, V> nodeOfCursor2 = cursor2.nodeStack.peek(); |
93 | if(nodeOfCursor1 != null && nodeOfCursor2 != null) { | 93 | if(nodeOfCursor1 != null && nodeOfCursor2 != null) { |
94 | return nodeOfCursor1.equals(nodeOfCursor2); | 94 | return nodeOfCursor1.equals(nodeOfCursor2); |
95 | } else { | 95 | } else { |
@@ -99,13 +99,13 @@ public class MapCursor<KEY,VALUE> implements Cursor<KEY,VALUE> { | |||
99 | 99 | ||
100 | /** | 100 | /** |
101 | * | 101 | * |
102 | * @param <KEY> | 102 | * @param <K> |
103 | * @param <VALUE> | 103 | * @param <V> |
104 | * @param cursor1 | 104 | * @param cursor1 |
105 | * @param cursor2 | 105 | * @param cursor2 |
106 | * @returnv Positive number if cursor 1 is behind, negative number if cursor 2 is behind, and 0 if they are at the same position. | 106 | * @returnv Positive number if cursor 1 is behind, negative number if cursor 2 is behind, and 0 if they are at the same position. |
107 | */ | 107 | */ |
108 | public static <KEY,VALUE> int compare(MapCursor<KEY,VALUE> cursor1, MapCursor<KEY,VALUE> cursor2) { | 108 | public static <K,V> int compare(MapCursor<K,V> cursor1, MapCursor<K,V> cursor2) { |
109 | // two cursors are equally deep | 109 | // two cursors are equally deep |
110 | Iterator<Integer> stack1 = cursor1.nodeIndexStack.descendingIterator(); | 110 | Iterator<Integer> stack1 = cursor1.nodeIndexStack.descendingIterator(); |
111 | Iterator<Integer> stack2 = cursor2.nodeIndexStack.descendingIterator(); | 111 | Iterator<Integer> stack2 = cursor2.nodeIndexStack.descendingIterator(); |