Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1884)

Unified Diff: app/tree_node_model.h

Issue 332016: Add a method to TreeNode to return total number of nodes in a subtree. Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/tree_node_model.h
===================================================================
--- app/tree_node_model.h (revision 29549)
+++ app/tree_node_model.h (working copy)
@@ -104,6 +104,17 @@
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) {
sky 2009/10/23 21:50:21 ()()->()
+ TreeNode<NodeType> *child = children_[i];
+ count += child->GetTotalNodeCount();
+ }
+ return count;
+ }
+
// Returns a child by index.
NodeType* GetChild(int index) {
DCHECK(index >= 0 && index < GetChildCount());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698