| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 DCHECK(i != children_.end()); | 91 DCHECK(i != children_.end()); |
| 92 node->parent_ = NULL; | 92 node->parent_ = NULL; |
| 93 children_.weak_erase(i); | 93 children_.weak_erase(i); |
| 94 return node; | 94 return node; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Removes all the children from this node. This does NOT delete the nodes. | 97 // Removes all the children from this node. This does NOT delete the nodes. |
| 98 void RemoveAll() { | 98 void RemoveAll() { |
| 99 for (size_t i = 0; i < children_.size(); ++i) | 99 for (size_t i = 0; i < children_.size(); ++i) |
| 100 children_[i]->parent_ = NULL; | 100 children_[i]->parent_ = NULL; |
| 101 children_.clear(); | 101 children_.weak_clear(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // Returns the parent node, or NULL if this is the root node. | 104 // Returns the parent node, or NULL if this is the root node. |
| 105 const NodeType* parent() const { return parent_; } | 105 const NodeType* parent() const { return parent_; } |
| 106 NodeType* parent() { return parent_; } | 106 NodeType* parent() { return parent_; } |
| 107 | 107 |
| 108 // Returns true if this is the root node. | 108 // Returns true if this is the root node. |
| 109 bool is_root() const { return parent_ == NULL; } | 109 bool is_root() const { return parent_ == NULL; } |
| 110 | 110 |
| 111 // Returns the number of children. | 111 // Returns the number of children. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 // The root. | 288 // The root. |
| 289 scoped_ptr<NodeType> root_; | 289 scoped_ptr<NodeType> root_; |
| 290 | 290 |
| 291 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); | 291 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); |
| 292 }; | 292 }; |
| 293 | 293 |
| 294 } // namespace ui | 294 } // namespace ui |
| 295 | 295 |
| 296 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_ | 296 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_ |
| OLD | NEW |