Merge branch 'features/JAL-2446NCList' into features/JAL-2574findFeaturesByColumn
[jalview.git] / src / jalview / datamodel / features / NCNode.java
index 5fb2d0d..c1be242 100644 (file)
@@ -1,5 +1,7 @@
 package jalview.datamodel.features;
 
+import jalview.datamodel.ContiguousI;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -49,7 +51,7 @@ class NCNode<V extends ContiguousI> implements ContiguousI
   {
     region = entry;
     subregions = newNCList;
-    size = 1 + newNCList.getSize();
+    size = 1 + newNCList.size();
   }
 
   /**
@@ -150,6 +152,7 @@ class NCNode<V extends ContiguousI> implements ContiguousI
     {
       subregions.add(entry);
     }
+    size++;
   }
 
   /**
@@ -227,4 +230,26 @@ class NCNode<V extends ContiguousI> implements ContiguousI
   {
     return subregions;
   }
+
+  /**
+   * Nulls the subregion reference if it is empty (after a delete entry
+   * operation)
+   */
+  void deleteSubRegionsIfEmpty()
+  {
+    if (subregions != null && subregions.size() == 0)
+    {
+      subregions = null;
+    }
+  }
+
+  /**
+   * Answers the (deep) size of this node i.e. the number of ranges it models
+   * 
+   * @return
+   */
+  int size()
+  {
+    return size;
+  }
 }