summaryrefslogtreecommitdiffstats
path: root/app/tree_node_model.h
diff options
context:
space:
mode:
Diffstat (limited to 'app/tree_node_model.h')
-rw-r--r--app/tree_node_model.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/tree_node_model.h b/app/tree_node_model.h
index 7d96438..8d8b713 100644
--- a/app/tree_node_model.h
+++ b/app/tree_node_model.h
@@ -104,6 +104,17 @@ class TreeNode : public TreeModelNode {
return static_cast<int>(children_->size());
}
+ // Returns the number of all nodes in teh subtree rooted at this node,
+ // including this node.
+ int GetTotalNodeCount() const {
+ int count = 1; // Start with one to include the node itself.
+ for (size_t i = 0; i < children_->size(); ++i) {
+ TreeNode<NodeType>* child = children_[i];
+ count += child->GetTotalNodeCount();
+ }
+ return count;
+ }
+
// Returns a child by index.
NodeType* GetChild(int index) {
DCHECK(index >= 0 && index < GetChildCount());