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

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

Issue 2230183002: ui: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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
« no previous file with comments | « ui/base/l10n/l10n_util_unittest.cc ('k') | ui/base/win/hwnd_subclass.cc » ('j') | 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) 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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // TreeNode ------------------------------------------------------------------- 62 // TreeNode -------------------------------------------------------------------
63 63
64 template <class NodeType> 64 template <class NodeType>
65 class TreeNode : public TreeModelNode { 65 class TreeNode : public TreeModelNode {
66 public: 66 public:
67 TreeNode() : parent_(NULL) {} 67 TreeNode() : parent_(NULL) {}
68 68
69 explicit TreeNode(const base::string16& title) 69 explicit TreeNode(const base::string16& title)
70 : title_(title), parent_(NULL) {} 70 : title_(title), parent_(NULL) {}
71 71
72 ~TreeNode() override { 72 ~TreeNode() override { base::STLDeleteElements(&children_); }
73 STLDeleteElements(&children_);
74 }
75 73
76 // Adds |node| as a child of this node, at |index|. 74 // Adds |node| as a child of this node, at |index|.
77 virtual void Add(NodeType* node, int index) { 75 virtual void Add(NodeType* node, int index) {
78 DCHECK(node); 76 DCHECK(node);
79 DCHECK_GE(index, 0); 77 DCHECK_GE(index, 0);
80 DCHECK_LE(index, child_count()); 78 DCHECK_LE(index, child_count());
81 // If |node| has a parent, remove it from its parent. 79 // If |node| has a parent, remove it from its parent.
82 NodeType* parent = node->parent_; 80 NodeType* parent = node->parent_;
83 if (parent) 81 if (parent)
84 parent->Remove(node); 82 parent->Remove(node);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 297
300 // The root. 298 // The root.
301 std::unique_ptr<NodeType> root_; 299 std::unique_ptr<NodeType> root_;
302 300
303 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); 301 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel);
304 }; 302 };
305 303
306 } // namespace ui 304 } // namespace ui
307 305
308 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_ 306 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_
OLDNEW
« no previous file with comments | « ui/base/l10n/l10n_util_unittest.cc ('k') | ui/base/win/hwnd_subclass.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698