aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MapCursor.java
diff options
context:
space:
mode:
authorLibravatar Oszkar Semerath <Oszkar Semerath@DESKTOP-DNR7JQ7>2021-07-29 01:17:22 +0200
committerLibravatar Oszkar Semerath <Oszkar Semerath@DESKTOP-DNR7JQ7>2021-07-29 01:17:22 +0200
commit7b2a6a2f29161b99ca14bb73ffd3fec4de461df8 (patch)
treed2129fdbd06419db3068afd180c80639fe6eaffe /Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MapCursor.java
parentAdding timeout to tests (diff)
downloadVIATRA-Generator-7b2a6a2f29161b99ca14bb73ffd3fec4de461df8.tar.gz
VIATRA-Generator-7b2a6a2f29161b99ca14bb73ffd3fec4de461df8.tar.zst
VIATRA-Generator-7b2a6a2f29161b99ca14bb73ffd3fec4de461df8.zip
Diffcursor fixes & continuous hash provider compare service.
Diffstat (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MapCursor.java')
-rw-r--r--Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MapCursor.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MapCursor.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MapCursor.java
index 5b9d5c7d..6c177611 100644
--- a/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MapCursor.java
+++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MapCursor.java
@@ -30,11 +30,12 @@ public class MapCursor<KEY,VALUE> implements Cursor<KEY,VALUE> {
30 // Initializing tree stack 30 // Initializing tree stack
31 super(); 31 super();
32 this.nodeStack = new ArrayDeque<>(); 32 this.nodeStack = new ArrayDeque<>();
33 this.nodeIndexStack = new ArrayDeque<>();
33 if(root != null) { 34 if(root != null) {
34 this.nodeStack.add(root); 35 this.nodeStack.add(root);
36 this.nodeIndexStack.push(IndexStart);
35 } 37 }
36 this.nodeIndexStack = new ArrayDeque<>(); 38
37 this.nodeIndexStack.push(IndexStart);
38 this.dataIndex = IndexStart; 39 this.dataIndex = IndexStart;
39 40
40 // Initializing cache 41 // Initializing cache
@@ -63,7 +64,11 @@ public class MapCursor<KEY,VALUE> implements Cursor<KEY,VALUE> {
63 throw new ConcurrentModificationException(); 64 throw new ConcurrentModificationException();
64 } 65 }
65 if(!isTerminated()) { 66 if(!isTerminated()) {
66 return this.nodeStack.peek().moveToNext(this); 67 boolean result = this.nodeStack.peek().moveToNext(this);
68 if(this.nodeIndexStack.size() != this.nodeStack.size()) {
69 throw new IllegalArgumentException("Node stack is corrupted by illegal moves!");
70 }
71 return result;
67 } 72 }
68 return false; 73 return false;
69 } 74 }
@@ -85,7 +90,11 @@ public class MapCursor<KEY,VALUE> implements Cursor<KEY,VALUE> {
85 public static <KEY,VALUE> boolean sameSubnode(MapCursor<KEY,VALUE> cursor1, MapCursor<KEY,VALUE> cursor2) { 90 public static <KEY,VALUE> boolean sameSubnode(MapCursor<KEY,VALUE> cursor1, MapCursor<KEY,VALUE> cursor2) {
86 Node<KEY, VALUE> nodeOfCursor1 = cursor1.nodeStack.peek(); 91 Node<KEY, VALUE> nodeOfCursor1 = cursor1.nodeStack.peek();
87 Node<KEY, VALUE> nodeOfCursor2 = cursor2.nodeStack.peek(); 92 Node<KEY, VALUE> nodeOfCursor2 = cursor2.nodeStack.peek();
88 return nodeOfCursor1.equals(nodeOfCursor2); 93 if(nodeOfCursor1 != null && nodeOfCursor2 != null) {
94 return nodeOfCursor1.equals(nodeOfCursor2);
95 } else {
96 return false;
97 }
89 } 98 }
90 99
91 /** 100 /**