JAL-1115 switch to lists in SequenceGroup
authorJim Procter <jprocter@dundee.ac.uk>
Thu, 12 Feb 2015 16:47:49 +0000 (16:47 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Thu, 12 Feb 2015 16:47:49 +0000 (16:47 +0000)
src/jalview/analysis/Grouping.java

index e4c9cea..7b6dda1 100644 (file)
  */
 package jalview.analysis;
 
+import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 
-import java.util.Hashtable;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Vector;
 
 /**
@@ -50,9 +53,9 @@ public class Grouping
           String[] selectedChars, List<SequenceGroup> list)
   {
     // TODO: determine how to get/recover input data for group generation
-    Hashtable gps = new Hashtable();
+    Map<String, List<SequenceI>> gps = new HashMap<String, List<SequenceI>>();
     int width = 0, i;
-    Hashtable pgroup = new Hashtable();
+    Map<String, SequenceGroup> pgroup = new HashMap<String, SequenceGroup>();
     if (list != null)
     {
       for (SequenceGroup sg : list)
@@ -66,32 +69,29 @@ public class Grouping
     for (i = 0; i < sequences.length; i++)
     {
       String schar = selectedChars[i];
-      SequenceGroup pgp = (SequenceGroup) pgroup
-              .get(((Object) sequences[i]).toString());
+      SequenceGroup pgp = pgroup.get(((Object) sequences[i]).toString());
       if (pgp != null)
       {
         schar = pgp.getName() + ":" + schar;
       }
-      Vector svec = (Vector) gps.get(schar);
+      List<SequenceI> svec = gps.get(schar);
       if (svec == null)
       {
-        svec = new Vector();
+        svec = new ArrayList<SequenceI>();
         gps.put(schar, svec);
       }
       if (width < sequences[i].getLength())
       {
         width = sequences[i].getLength();
       }
-      svec.addElement(sequences[i]);
+      svec.add(sequences[i]);
     }
     // make some groups
-    java.util.Enumeration sge = gps.keys();
     SequenceGroup[] groups = new SequenceGroup[gps.size()];
     i = 0;
-    while (sge.hasMoreElements())
+    for (String key : gps.keySet())
     {
-      String key = (String) sge.nextElement();
-      SequenceGroup group = new SequenceGroup((Vector) gps.get(key),
+      SequenceGroup group = new SequenceGroup(gps.get(key),
               "Subseq: " + key, null, true, true, false, 0, width - 1);
 
       groups[i++] = group;