JAL-2446 various get and find methods added with test coverage
[jalview.git] / src / jalview / datamodel / features / NCNode.java
index ab10f67..6af913a 100644 (file)
@@ -18,6 +18,9 @@ class NCNode<V extends ContiguousI>
 
   private V region;
 
+  /*
+   * null, or an object holding contained subregions of this nodes region
+   */
   private NCList<V> subregions;
 
   /**
@@ -46,7 +49,7 @@ class NCNode<V extends ContiguousI>
   {
     region = entry;
     subregions = newNCList;
-    // size = 1 + newNCList.size();
+    size = 1 + newNCList.getSize();
   }
 
   /**
@@ -112,7 +115,7 @@ class NCNode<V extends ContiguousI>
    * @param to
    * @param result
    */
-  void addOverlaps(long from, long to, List<V> result)
+  void findOverlaps(long from, long to, List<V> result)
   {
     if (region.getBegin() <= to && region.getEnd() >= from)
     {
@@ -161,4 +164,18 @@ class NCNode<V extends ContiguousI>
     }
     return subregions.isValid(getStart(), getEnd());
   }
+
+  /**
+   * Adds all contained entries to the given list
+   * 
+   * @param entries
+   */
+  void getEntries(List<V> entries)
+  {
+    entries.add(region);
+    if (subregions != null)
+    {
+      subregions.getEntries(entries);
+    }
+  }
 }