]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Use ArrayList (instead of HashSet) to store changes 67/3167/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 29 Aug 2019 07:46:08 +0000 (10:46 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 29 Aug 2019 07:46:08 +0000 (10:46 +0300)
gitlab #11

Change-Id: I7d5a2c1f462c6de3c401288420350e25f650147f

org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateList.java

index 21cde66e1c461e3b4ebb70444b3cccbf3fc282f2..2267ebec6f47e8ec101a39d1945e19d99aa1325a 100644 (file)
@@ -14,20 +14,20 @@ import org.simantics.interop.test.GraphChanges.Modification;
 import org.simantics.utils.datastructures.Pair;
 
 public class UpdateList {
-       private HashSet<PropertyChange> changes;
+       private List<PropertyChange> changes;
        
        public UpdateList() {
-               changes = new HashSet<>();
+               changes = new ArrayList<>();
        }
        
        public UpdateList(Collection<PropertyChange> changes) {
-               this.changes = new HashSet<>(changes);
+               this.changes = new ArrayList<>(changes);
        }
        
        public UpdateList(GraphChanges graphChanges, Collection<Modification> coll) {
-               this.changes = new HashSet<>();
+               this.changes = new ArrayList<>();
                for (Modification p : coll) {
-                       changes.add(create(graphChanges, p.getLeftSub(),p.getRightSub(),new Pair<Statement, Statement>(p.getLeftStm(), p.getRightStm())));
+                       addChange(create(graphChanges, p.getLeftSub(),p.getRightSub(),new Pair<Statement, Statement>(p.getLeftStm(), p.getRightStm())));
                }
        }
        
@@ -40,7 +40,8 @@ public class UpdateList {
        }
 
        public void addChange(PropertyChange change) {
-               changes.add(change);
+           if (!changes.contains(change))
+               changes.add(change);
        }
        
        public void removeChange(PropertyChange change) {