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

Side by Side Diff: ui/base/models/tree_node_model.h

Issue 7003039: ui/base/models: Add empty() accessor to TreeNode class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sky review Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/models/tree_node_iterator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_BASE_MODELS_TREE_NODE_MODEL_H_ 5 #ifndef UI_BASE_MODELS_TREE_NODE_MODEL_H_
6 #define UI_BASE_MODELS_TREE_NODE_MODEL_H_ 6 #define UI_BASE_MODELS_TREE_NODE_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Returns the parent node, or NULL if this is the root node. 105 // Returns the parent node, or NULL if this is the root node.
106 const NodeType* parent() const { return parent_; } 106 const NodeType* parent() const { return parent_; }
107 NodeType* parent() { return parent_; } 107 NodeType* parent() { return parent_; }
108 108
109 // Returns true if this is the root node. 109 // Returns true if this is the root node.
110 bool is_root() const { return parent_ == NULL; } 110 bool is_root() const { return parent_ == NULL; }
111 111
112 // Returns the number of children. 112 // Returns the number of children.
113 int child_count() const { return static_cast<int>(children_->size()); } 113 int child_count() const { return static_cast<int>(children_->size()); }
114 114
115 // Returns true if this node has no children.
116 bool empty() const { return children_.empty(); }
117
115 // Returns the number of all nodes in the subtree rooted at this node, 118 // Returns the number of all nodes in the subtree rooted at this node,
116 // including this node. 119 // including this node.
117 int GetTotalNodeCount() const { 120 int GetTotalNodeCount() const {
118 int count = 1; // Start with one to include the node itself. 121 int count = 1; // Start with one to include the node itself.
119 for (size_t i = 0; i < children_->size(); ++i) 122 for (size_t i = 0; i < children_->size(); ++i)
120 count += children_[i]->GetTotalNodeCount(); 123 count += children_[i]->GetTotalNodeCount();
121 return count; 124 return count;
122 } 125 }
123 126
124 // Returns the node at |index|. 127 // Returns the node at |index|.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 289
287 // The root. 290 // The root.
288 scoped_ptr<NodeType> root_; 291 scoped_ptr<NodeType> root_;
289 292
290 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); 293 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel);
291 }; 294 };
292 295
293 } // namespace ui 296 } // namespace ui
294 297
295 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_ 298 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_
OLDNEW
« no previous file with comments | « ui/base/models/tree_node_iterator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698