diff options
Diffstat (limited to 'subprojects')
-rw-r--r-- | subprojects/store/src/main/java/tools/refinery/store/map/internal/DeltaDiffCursor.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/subprojects/store/src/main/java/tools/refinery/store/map/internal/DeltaDiffCursor.java b/subprojects/store/src/main/java/tools/refinery/store/map/internal/DeltaDiffCursor.java index 49ea1f67..8ddca8ec 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/map/internal/DeltaDiffCursor.java +++ b/subprojects/store/src/main/java/tools/refinery/store/map/internal/DeltaDiffCursor.java | |||
@@ -11,6 +11,7 @@ public class DeltaDiffCursor<K, V> implements DiffCursor<K, V> { | |||
11 | final List<MapDelta<K, V>[]> backwardTransactions; | 11 | final List<MapDelta<K, V>[]> backwardTransactions; |
12 | final List<MapDelta<K, V>[]> forwardTransactions; | 12 | final List<MapDelta<K, V>[]> forwardTransactions; |
13 | 13 | ||
14 | boolean started; | ||
14 | /** | 15 | /** |
15 | * Denotes the direction of traversal. False means backwards, true means | 16 | * Denotes the direction of traversal. False means backwards, true means |
16 | * forward. | 17 | * forward. |
@@ -35,6 +36,7 @@ public class DeltaDiffCursor<K, V> implements DiffCursor<K, V> { | |||
35 | direction = true; | 36 | direction = true; |
36 | listIndex = -1; | 37 | listIndex = -1; |
37 | } | 38 | } |
39 | started = false; | ||
38 | } | 40 | } |
39 | 41 | ||
40 | protected MapDelta<K, V> getCurrentDelta() { | 42 | protected MapDelta<K, V> getCurrentDelta() { |
@@ -65,7 +67,10 @@ public class DeltaDiffCursor<K, V> implements DiffCursor<K, V> { | |||
65 | 67 | ||
66 | @Override | 68 | @Override |
67 | public boolean move() { | 69 | public boolean move() { |
68 | if (isTerminated()) { | 70 | if(!started) { |
71 | started = true; | ||
72 | return !isTerminated(); | ||
73 | } else if (isTerminated()) { | ||
69 | return false; | 74 | return false; |
70 | } else { | 75 | } else { |
71 | if (this.direction) { | 76 | if (this.direction) { |
@@ -119,11 +124,19 @@ public class DeltaDiffCursor<K, V> implements DiffCursor<K, V> { | |||
119 | 124 | ||
120 | @Override | 125 | @Override |
121 | public V getFromValue() { | 126 | public V getFromValue() { |
122 | return getCurrentDelta().getOldValue(); | 127 | if(this.direction) { |
128 | return getCurrentDelta().getOldValue(); | ||
129 | } else { | ||
130 | return getCurrentDelta().getNewValue(); | ||
131 | } | ||
123 | } | 132 | } |
124 | 133 | ||
125 | @Override | 134 | @Override |
126 | public V getToValue() { | 135 | public V getToValue() { |
127 | return getCurrentDelta().getNewValue(); | 136 | if(this.direction) { |
137 | return getCurrentDelta().getNewValue(); | ||
138 | } else { | ||
139 | return getCurrentDelta().getOldValue(); | ||
140 | } | ||
128 | } | 141 | } |
129 | } | 142 | } |