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

Side by Side Diff: sdk/lib/collection/splay_tree.dart

Issue 148523006: Fix bug in internal SplayTreeIterator constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added test. Created 6 years, 10 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 | « no previous file | tests/corelib/splay_tree_test.dart » ('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 Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.collection; 5 part of dart.collection;
6 6
7 typedef bool _Predicate<T>(T value); 7 typedef bool _Predicate<T>(T value);
8 8
9 /** 9 /**
10 * A node in a splay tree. It holds the sorting key and the left 10 * A node in a splay tree. It holds the sorting key and the left
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 _modificationCount = tree._modificationCount, 518 _modificationCount = tree._modificationCount,
519 _splayCount = tree._splayCount { 519 _splayCount = tree._splayCount {
520 _findLeftMostDescendent(tree._root); 520 _findLeftMostDescendent(tree._root);
521 } 521 }
522 522
523 _SplayTreeIterator.startAt(_SplayTree tree, var startKey) 523 _SplayTreeIterator.startAt(_SplayTree tree, var startKey)
524 : _tree = tree, 524 : _tree = tree,
525 _modificationCount = tree._modificationCount { 525 _modificationCount = tree._modificationCount {
526 int compare = tree._splay(startKey); 526 int compare = tree._splay(startKey);
527 _splayCount = tree._splayCount; 527 _splayCount = tree._splayCount;
528 _findLeftMostDescendent(compare < 0 ? tree._root.right : tree._root); 528 if (compare < 0) {
529 // Don't include the root, start at the next element after the root.
530 _findLeftMostDescendent(tree._root.right);
531 } else {
532 _workList.add(tree._root);
533 }
529 } 534 }
530 535
531 T get current { 536 T get current {
532 if (_currentNode == null) return null; 537 if (_currentNode == null) return null;
533 return _getValue(_currentNode); 538 return _getValue(_currentNode);
534 } 539 }
535 540
536 _SplayTreeNode _findStartNode(T key) {
537
538 }
539
540 void _findLeftMostDescendent(_SplayTreeNode node) { 541 void _findLeftMostDescendent(_SplayTreeNode node) {
541 while (node != null) { 542 while (node != null) {
542 _workList.add(node); 543 _workList.add(node);
543 node = node.left; 544 node = node.left;
544 } 545 }
545 } 546 }
546 547
547 /** 548 /**
548 * Called when the tree structure of the tree has changed. 549 * Called when the tree structure of the tree has changed.
549 * 550 *
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 818
818 bool containsAll(Iterable<Object> other) { 819 bool containsAll(Iterable<Object> other) {
819 for (var element in other) { 820 for (var element in other) {
820 if (!this.contains(element)) return false; 821 if (!this.contains(element)) return false;
821 } 822 }
822 return true; 823 return true;
823 } 824 }
824 825
825 void clear() { _clear(); } 826 void clear() { _clear(); }
826 } 827 }
OLDNEW
« no previous file with comments | « no previous file | tests/corelib/splay_tree_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698