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

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

Issue 1154263003: Revert "Make EfficientLength public, as EfficientLengthIterable." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « 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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 } 593 }
594 _currentNode = _workList.removeLast(); 594 _currentNode = _workList.removeLast();
595 _findLeftMostDescendent(_currentNode.right); 595 _findLeftMostDescendent(_currentNode.right);
596 return true; 596 return true;
597 } 597 }
598 598
599 T _getValue(_SplayTreeNode node); 599 T _getValue(_SplayTreeNode node);
600 } 600 }
601 601
602 class _SplayTreeKeyIterable<K> extends Iterable<K> 602 class _SplayTreeKeyIterable<K> extends Iterable<K>
603 implements EfficientLengthIterable<K> { 603 implements EfficientLength {
604 _SplayTree<K> _tree; 604 _SplayTree<K> _tree;
605 _SplayTreeKeyIterable(this._tree); 605 _SplayTreeKeyIterable(this._tree);
606 int get length => _tree._count; 606 int get length => _tree._count;
607 bool get isEmpty => _tree._count == 0; 607 bool get isEmpty => _tree._count == 0;
608 Iterator<K> get iterator => new _SplayTreeKeyIterator<K>(_tree); 608 Iterator<K> get iterator => new _SplayTreeKeyIterator<K>(_tree);
609 609
610 Set<K> toSet() { 610 Set<K> toSet() {
611 var setOrMap = _tree; // Both have _comparator and _validKey. 611 var setOrMap = _tree; // Both have _comparator and _validKey.
612 SplayTreeSet<K> set = 612 SplayTreeSet<K> set =
613 new SplayTreeSet<K>(setOrMap._comparator, setOrMap._validKey); 613 new SplayTreeSet<K>(setOrMap._comparator, setOrMap._validKey);
614 set._count = _tree._count; 614 set._count = _tree._count;
615 set._root = set._copyNode(_tree._root); 615 set._root = set._copyNode(_tree._root);
616 return set; 616 return set;
617 } 617 }
618 } 618 }
619 619
620 class _SplayTreeValueIterable<K, V> extends Iterable<V> 620 class _SplayTreeValueIterable<K, V> extends Iterable<V>
621 implements EfficientLengthIterable<V> { 621 implements EfficientLength {
622 SplayTreeMap<K, V> _map; 622 SplayTreeMap<K, V> _map;
623 _SplayTreeValueIterable(this._map); 623 _SplayTreeValueIterable(this._map);
624 int get length => _map._count; 624 int get length => _map._count;
625 bool get isEmpty => _map._count == 0; 625 bool get isEmpty => _map._count == 0;
626 Iterator<V> get iterator => new _SplayTreeValueIterator<K, V>(_map); 626 Iterator<V> get iterator => new _SplayTreeValueIterator<K, V>(_map);
627 } 627 }
628 628
629 class _SplayTreeKeyIterator<K> extends _SplayTreeIterator<K> { 629 class _SplayTreeKeyIterator<K> extends _SplayTreeIterator<K> {
630 _SplayTreeKeyIterator(_SplayTree<K> map): super(map); 630 _SplayTreeKeyIterator(_SplayTree<K> map): super(map);
631 K _getValue(_SplayTreeNode node) => node.key; 631 K _getValue(_SplayTreeNode node) => node.key;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 return new _SplayTreeNode<E>(node.key)..left = _copyNode(node.left) 829 return new _SplayTreeNode<E>(node.key)..left = _copyNode(node.left)
830 ..right = _copyNode(node.right); 830 ..right = _copyNode(node.right);
831 } 831 }
832 832
833 void clear() { _clear(); } 833 void clear() { _clear(); }
834 834
835 Set<E> toSet() => _clone(); 835 Set<E> toSet() => _clone();
836 836
837 String toString() => IterableBase.iterableToFullString(this, '{', '}'); 837 String toString() => IterableBase.iterableToFullString(this, '{', '}');
838 } 838 }
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