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

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

Issue 2467283003: Revert "Make EfficientLength extend Iterable." (Closed)
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « sdk/lib/collection/queue.dart ('k') | sdk/lib/core/iterable.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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 _rebuildWorkList(_currentNode); 600 _rebuildWorkList(_currentNode);
601 } 601 }
602 _currentNode = _workList.removeLast(); 602 _currentNode = _workList.removeLast();
603 _findLeftMostDescendent(_currentNode.right); 603 _findLeftMostDescendent(_currentNode.right);
604 return true; 604 return true;
605 } 605 }
606 606
607 T _getValue(_SplayTreeNode<K> node); 607 T _getValue(_SplayTreeNode<K> node);
608 } 608 }
609 609
610 class _SplayTreeKeyIterable<K> extends EfficientLengthIterable<K> { 610 class _SplayTreeKeyIterable<K> extends Iterable<K>
611 implements EfficientLength {
611 _SplayTree<K, _SplayTreeNode<K>> _tree; 612 _SplayTree<K, _SplayTreeNode<K>> _tree;
612 _SplayTreeKeyIterable(this._tree); 613 _SplayTreeKeyIterable(this._tree);
613 int get length => _tree._count; 614 int get length => _tree._count;
614 bool get isEmpty => _tree._count == 0; 615 bool get isEmpty => _tree._count == 0;
615 Iterator<K> get iterator => new _SplayTreeKeyIterator<K>(_tree); 616 Iterator<K> get iterator => new _SplayTreeKeyIterator<K>(_tree);
616 617
617 Set<K> toSet() { 618 Set<K> toSet() {
618 SplayTreeSet<K> set = 619 SplayTreeSet<K> set =
619 new SplayTreeSet<K>(_tree._comparator, _tree._validKey); 620 new SplayTreeSet<K>(_tree._comparator, _tree._validKey);
620 set._count = _tree._count; 621 set._count = _tree._count;
621 set._root = set._copyNode(_tree._root); 622 set._root = set._copyNode(_tree._root);
622 return set; 623 return set;
623 } 624 }
624 } 625 }
625 626
626 class _SplayTreeValueIterable<K, V> extends EfficientLengthIterable<V> { 627 class _SplayTreeValueIterable<K, V> extends Iterable<V>
628 implements EfficientLength {
627 SplayTreeMap<K, V> _map; 629 SplayTreeMap<K, V> _map;
628 _SplayTreeValueIterable(this._map); 630 _SplayTreeValueIterable(this._map);
629 int get length => _map._count; 631 int get length => _map._count;
630 bool get isEmpty => _map._count == 0; 632 bool get isEmpty => _map._count == 0;
631 Iterator<V> get iterator => new _SplayTreeValueIterator<K, V>(_map); 633 Iterator<V> get iterator => new _SplayTreeValueIterator<K, V>(_map);
632 } 634 }
633 635
634 class _SplayTreeKeyIterator<K> extends _SplayTreeIterator<K, K> { 636 class _SplayTreeKeyIterator<K> extends _SplayTreeIterator<K, K> {
635 _SplayTreeKeyIterator(_SplayTree<K, _SplayTreeNode<K>> map): super(map); 637 _SplayTreeKeyIterator(_SplayTree<K, _SplayTreeNode<K>> map): super(map);
636 K _getValue(_SplayTreeNode<K> node) => node.key; 638 K _getValue(_SplayTreeNode<K> node) => node.key;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 return new _SplayTreeNode<E>(node.key)..left = _copyNode(node.left) 849 return new _SplayTreeNode<E>(node.key)..left = _copyNode(node.left)
848 ..right = _copyNode(node.right); 850 ..right = _copyNode(node.right);
849 } 851 }
850 852
851 void clear() { _clear(); } 853 void clear() { _clear(); }
852 854
853 Set<E> toSet() => _clone(); 855 Set<E> toSet() => _clone();
854 856
855 String toString() => IterableBase.iterableToFullString(this, '{', '}'); 857 String toString() => IterableBase.iterableToFullString(this, '{', '}');
856 } 858 }
OLDNEW
« no previous file with comments | « sdk/lib/collection/queue.dart ('k') | sdk/lib/core/iterable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698