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

Unified Diff: ui/base/models/tree_node_iterator.h

Issue 8759017: BookmarkModel cleanup. synced_node is now mobile_node and I'm nuking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to trunk fix sync_integration_tests and extension test Created 9 years, 1 month 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 | « net/tools/testserver/chromiumsync.py ('k') | ui/base/models/tree_node_iterator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/models/tree_node_iterator.h
diff --git a/ui/base/models/tree_node_iterator.h b/ui/base/models/tree_node_iterator.h
index 5a05df9fb1497453690f4139793f7ce126eddc61..26d6deaaa90c1fe3d5086a7001528923fa01eb48 100644
--- a/ui/base/models/tree_node_iterator.h
+++ b/ui/base/models/tree_node_iterator.h
@@ -23,27 +23,7 @@ namespace ui {
template <class NodeType>
class TreeNodeIterator {
public:
- // This contructor accepts an optional filter function |prune| which could be
- // used to prune complete branches of the tree. The filter function will be
- // evaluated on each tree node and if it evaluates to true the node and all
- // its descendants will be skipped by the iterator.
- TreeNodeIterator(NodeType* node, bool (*prune)(NodeType*))
- : prune_(prune) {
- int index = 0;
-
- // Move forward through the children list until the first non prunable node.
- // This is to satisfy the iterator invariant that the current index in the
- // Position at the top of the _positions list must point to a node the
- // iterator will be returning.
- for (; index < node->child_count(); ++index)
- if (!prune || !prune(node->GetChild(index)))
- break;
-
- if (index < node->child_count())
- positions_.push(Position<NodeType>(node, index));
- }
-
- explicit TreeNodeIterator(NodeType* node) : prune_(NULL) {
+ explicit TreeNodeIterator(NodeType* node) {
if (!node->empty())
positions_.push(Position<NodeType>(node, 0));
}
@@ -67,18 +47,9 @@ class TreeNodeIterator {
// Iterate over result's children.
positions_.push(Position<NodeType>(result, 0));
- // Advance to next valid node by skipping over the pruned nodes and the
- // empty Positions. At the end of this loop two cases are possible:
- // - the current index of the top() Position points to a valid node
- // - the _position list is empty, the iterator has_next() will return false.
- while (!positions_.empty()) {
- if (positions_.top().index >= positions_.top().node->child_count())
- positions_.pop(); // This Position is all processed, move to the next.
- else if (prune_ &&
- prune_(positions_.top().node->GetChild(positions_.top().index)))
- positions_.top().index++; // Prune the branch.
- else
- break; // Now positioned at the next node to be returned.
+ while (!positions_.empty() &&
+ positions_.top().index >= positions_.top().node->child_count()) {
+ positions_.pop(); // This Position is all processed, move to the next.
}
return result;
@@ -95,7 +66,6 @@ class TreeNodeIterator {
};
std::stack<Position<NodeType> > positions_;
- bool (*prune_)(NodeType*);
DISALLOW_COPY_AND_ASSIGN(TreeNodeIterator);
};
« no previous file with comments | « net/tools/testserver/chromiumsync.py ('k') | ui/base/models/tree_node_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698