JAL-2576 Proposed fix bug/JAL-2576
authorkiramt <k.mourao@dundee.ac.uk>
Fri, 2 Jun 2017 13:10:57 +0000 (14:10 +0100)
committerkiramt <k.mourao@dundee.ac.uk>
Fri, 2 Jun 2017 13:10:57 +0000 (14:10 +0100)
src/jalview/datamodel/Alignment.java
src/jalview/util/LinkedIdentityHashSet.java

index 5d91b36..f5e6fc7 100755 (executable)
@@ -1067,21 +1067,18 @@ public class Alignment implements AlignmentI
         currentSeq = currentSeq.createDatasetSequence();
       }
     }
-    if (seqs.contains(currentSeq))
-    {
-      return;
-    }
+
     List<SequenceI> toProcess = new ArrayList<>();
     toProcess.add(currentSeq);
     while (toProcess.size() > 0)
     {
       // use a queue ?
       SequenceI curDs = toProcess.remove(0);
-      if (seqs.contains(curDs))
+
+      if (!seqs.add(curDs))
       {
         continue;
       }
-      seqs.add(curDs);
       // iterate over database references, making sure we add forward referenced
       // sequences
       if (curDs.getDBRefs() != null)
index bce540f..7f109ec 100644 (file)
@@ -34,7 +34,7 @@ import java.util.LinkedHashMap;
  */
 public class LinkedIdentityHashSet<E> extends AbstractSet<E>
 {
-  LinkedHashMap<IdentityWrapper, IdentityWrapper> set = new LinkedHashMap<IdentityWrapper, IdentityWrapper>();
+  LinkedHashMap<IdentityWrapper, IdentityWrapper> set = new LinkedHashMap<>();
 
   static class IdentityWrapper
   {
@@ -51,7 +51,7 @@ public class LinkedIdentityHashSet<E> extends AbstractSet<E>
     @Override
     public boolean equals(Object obj)
     {
-      return this.obj == obj;
+      return this.obj == ((IdentityWrapper) obj).obj;
     }
 
     @Override