aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers
diff options
context:
space:
mode:
authorLibravatar Oszkar Semerath <Oszkar Semerath@DESKTOP-DNR7JQ7>2021-07-25 02:57:41 +0200
committerLibravatar Oszkar Semerath <Oszkar Semerath@DESKTOP-DNR7JQ7>2021-07-25 02:57:41 +0200
commit1f550e594dc7c756ab26e7d6ea83e01d7e16bf8d (patch)
tree695c4c82c7798d7c16bf7d648ad58681c2dc52db /Solvers
parentComparation tests between commiting and non-commiting maps. (diff)
downloadVIATRA-Generator-1f550e594dc7c756ab26e7d6ea83e01d7e16bf8d.tar.gz
VIATRA-Generator-1f550e594dc7c756ab26e7d6ea83e01d7e16bf8d.tar.zst
VIATRA-Generator-1f550e594dc7c756ab26e7d6ea83e01d7e16bf8d.zip
Removed equals from hash provider, as nodes are compared without it.
Diffstat (limited to 'Solvers')
-rw-r--r--Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/ContinousHashProvider.java25
-rw-r--r--Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java12
-rw-r--r--Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MutableNode.java4
3 files changed, 22 insertions, 19 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/ContinousHashProvider.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/ContinousHashProvider.java
index c4567458..56c5fefd 100644
--- a/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/ContinousHashProvider.java
+++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/ContinousHashProvider.java
@@ -19,16 +19,17 @@ public interface ContinousHashProvider<KEY> {
19 * @return A hash code. 19 * @return A hash code.
20 */ 20 */
21 public int getHash(KEY key, int index); 21 public int getHash(KEY key, int index);
22 /** 22// /**
23 * Compares the equivalnce of two objects {@code key1} and {@code key2}. It has the contracts of a equivalence relation: 23// * Compares the equivalence of two objects {@code key1} and {@code key2}. It has the contracts of a equivalence relation:
24 * <ul> 24// * <ul>
25 * <li> Reflexive: {@code equals(key,key) == true}.</li> 25// * <li> Reflexive: {@code equals(key,key) == true}.</li>
26 * <li> Symmetric: {@code equals(key1,key2) == equals(key2,key1)}.</li> 26// * <li> Symmetric: {@code equals(key1,key2) == equals(key2,key1)}.</li>
27 * <li> Transitive: {@code equals(key1,key2) == true} and {@code equals(key2,key3) == true} then {@code equals(key1,key3) == true}.</li> 27// * <li> Transitive: {@code equals(key1,key2) == true} and {@code equals(key2,key3) == true} then {@code equals(key1,key3) == true}.</li>
28 * </ul> 28// * </ul>
29 * @param key1 First data object. 29// * TODO: clarify relation to Object.equals() on keys
30 * @param key2 Second data object. 30// * @param key1 First data object.
31 * @return whether {@code key1} and {@code key2} are equivalent with respect to an equivalence relation represented by the given . 31// * @param key2 Second data object.
32 */ 32// * @return whether {@code key1} and {@code key2} are equivalent with respect to an equivalence relation represented by the given .
33 public boolean equals(KEY key1, KEY key2); 33// */
34// public boolean equals(KEY key1, KEY key2);
34} 35}
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java
index 19b0720d..49b98863 100644
--- a/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java
+++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java
@@ -100,7 +100,7 @@ public class ImmutableNode<KEY, VALUE> extends Node<KEY, VALUE> {
100 if((dataMap & bitposition) != 0) { 100 if((dataMap & bitposition) != 0) {
101 int keyIndex = 2*index(dataMap, bitposition); 101 int keyIndex = 2*index(dataMap, bitposition);
102 KEY keyCandidate = (KEY) content[keyIndex]; 102 KEY keyCandidate = (KEY) content[keyIndex];
103 if(hashProvider.equals(keyCandidate, key)) { 103 if(keyCandidate.equals(key)) {
104 return (VALUE) content[keyIndex+1]; 104 return (VALUE) content[keyIndex+1];
105 } else { 105 } else {
106 return defaultValue; 106 return defaultValue;
@@ -128,7 +128,7 @@ public class ImmutableNode<KEY, VALUE> extends Node<KEY, VALUE> {
128 if((dataMap & bitposition) != 0) { 128 if((dataMap & bitposition) != 0) {
129 int keyIndex = 2*index(dataMap, bitposition); 129 int keyIndex = 2*index(dataMap, bitposition);
130 KEY keyCandidate = (KEY) content[keyIndex]; 130 KEY keyCandidate = (KEY) content[keyIndex];
131 if(hashProvider.equals(keyCandidate, key)) { 131 if(keyCandidate.equals(key)) {
132 if(value == defaultValue) { 132 if(value == defaultValue) {
133 // delete 133 // delete
134 MutableNode<KEY, VALUE> mutable = this.toMutable(); 134 MutableNode<KEY, VALUE> mutable = this.toMutable();
@@ -231,8 +231,10 @@ public class ImmutableNode<KEY, VALUE> extends Node<KEY, VALUE> {
231 // 2.1 found next subnode, move down to the subnode 231 // 2.1 found next subnode, move down to the subnode
232 Node<KEY, VALUE> subnode = (Node<KEY, VALUE>) this.content[this.content.length-1-newNodeIndex]; 232 Node<KEY, VALUE> subnode = (Node<KEY, VALUE>) this.content[this.content.length-1-newNodeIndex];
233 cursor.dataIndex = MapCursor.IndexStart; 233 cursor.dataIndex = MapCursor.IndexStart;
234 cursor.nodeStack.push(subnode); 234 cursor.nodeIndexStack.pop();
235 cursor.nodeIndexStack.push(newNodeIndex); 235 cursor.nodeIndexStack.push(newNodeIndex);
236 cursor.nodeIndexStack.push(MapCursor.IndexStart);
237 cursor.nodeStack.push(subnode);
236 return subnode.moveToNext(cursor); 238 return subnode.moveToNext(cursor);
237 } else { 239 } else {
238 // 3. no subnode found, move up 240 // 3. no subnode found, move up
@@ -330,8 +332,8 @@ public class ImmutableNode<KEY, VALUE> extends Node<KEY, VALUE> {
330 if(key != null) { 332 if(key != null) {
331 // Check whether a new Key-Value pair can fit into the immutable container 333 // Check whether a new Key-Value pair can fit into the immutable container
332 if(datas*2+nodes+2 <= immutableLength) { 334 if(datas*2+nodes+2 <= immutableLength) {
333 if( mutable.content[datas*2] != key || 335 if( !immutable.content[datas*2].equals(key) ||
334 mutable.content[datas*2+1] != immutable.content[i*2+1]) 336 !immutable.content[datas*2+1].equals(mutable.content[i*2+1]))
335 { 337 {
336 return false; 338 return false;
337 } 339 }
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MutableNode.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MutableNode.java
index 4d216785..eaded957 100644
--- a/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MutableNode.java
+++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/src/org/eclipse/viatra/solver/data/map/internal/MutableNode.java
@@ -59,7 +59,7 @@ public class MutableNode<KEY,VALUE> extends Node<KEY,VALUE> {
59 int selectedHashFragment = hashFragment(hash,shiftDepth(depth)); 59 int selectedHashFragment = hashFragment(hash,shiftDepth(depth));
60 KEY keyCandidate = (KEY) this.content[2*selectedHashFragment]; 60 KEY keyCandidate = (KEY) this.content[2*selectedHashFragment];
61 if(keyCandidate != null) { 61 if(keyCandidate != null) {
62 if(hashProvider.equals(keyCandidate, key)) { 62 if(keyCandidate.equals(key)) {
63 return (VALUE) this.content[2*selectedHashFragment+1]; 63 return (VALUE) this.content[2*selectedHashFragment+1];
64 } else { 64 } else {
65 return defaultValue; 65 return defaultValue;
@@ -90,7 +90,7 @@ public class MutableNode<KEY,VALUE> extends Node<KEY,VALUE> {
90 KEY keyCandidate = (KEY) content[2*selectedHashFragment]; 90 KEY keyCandidate = (KEY) content[2*selectedHashFragment];
91 if(keyCandidate != null) { 91 if(keyCandidate != null) {
92 // If has key 92 // If has key
93 if(hashProvider.equals(keyCandidate,key)) { 93 if(keyCandidate.equals(key)) {
94 // The key is equals to an existing key -> update entry 94 // The key is equals to an existing key -> update entry
95 if(value == defaultValue) { 95 if(value == defaultValue) {
96 return removeEntry(selectedHashFragment); 96 return removeEntry(selectedHashFragment);