JAL-2446 various get and find methods added with test coverage
[jalview.git] / src / jalview / datamodel / features / NCList.java
index 40b062a..6a9f750 100644 (file)
@@ -9,7 +9,10 @@ import java.util.List;
  * An adapted implementation of NCList as described in the paper
  * 
  * <pre>
- * todo
+ * Nested Containment List (NCList): a new algorithm for accelerating
+ * interval query of genome alignment and interval databases
+ * - Alexander V. Alekseyenko, Christopher J. Lee
+ * https://doi.org/10.1093/bioinformatics/btl647
  * </pre>
  */
 public class NCList<T extends ContiguousI>
@@ -312,7 +315,7 @@ public class NCList<T extends ContiguousI>
          */
         break;
       }
-      candidate.addOverlaps(from, to, result);
+      candidate.findOverlaps(from, to, result);
     }
 
   }
@@ -461,4 +464,29 @@ public class NCList<T extends ContiguousI>
   {
     return size;
   }
+
+  /**
+   * Returns a list of all entries stored
+   * 
+   * @return
+   */
+  public List<T> getEntries()
+  {
+    List<T> result = new ArrayList<T>();
+    getEntries(result);
+    return result;
+  }
+
+  /**
+   * Adds all contained entries to the given list
+   * 
+   * @param result
+   */
+  void getEntries(List<T> result)
+  {
+    for (NCNode<T> subrange : subranges)
+    {
+      subrange.getEntries(result);
+    }
+  }
 }