OLD | NEW |
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 /** | 7 /** |
8 * A node in a splay tree. It holds the sorting key and the left | 8 * A node in a splay tree. It holds the sorting key and the left |
9 * and right children in the tree. | 9 * and right children in the tree. |
10 */ | 10 */ |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 _rebuildWorkList(_currentNode); | 498 _rebuildWorkList(_currentNode); |
499 } | 499 } |
500 _currentNode = _workList.removeLast(); | 500 _currentNode = _workList.removeLast(); |
501 _findLeftMostDescendent(_currentNode.right); | 501 _findLeftMostDescendent(_currentNode.right); |
502 return true; | 502 return true; |
503 } | 503 } |
504 | 504 |
505 T _getValue(_SplayTreeNode node); | 505 T _getValue(_SplayTreeNode node); |
506 } | 506 } |
507 | 507 |
508 class _SplayTreeKeyIterable<K> extends Iterable<K> { | 508 class _SplayTreeKeyIterable<K> extends IterableBase<K> { |
509 _SplayTree<K> _tree; | 509 _SplayTree<K> _tree; |
510 _SplayTreeKeyIterable(this._tree); | 510 _SplayTreeKeyIterable(this._tree); |
511 int get length => _tree._count; | 511 int get length => _tree._count; |
512 bool get isEmpty => _tree._count == 0; | 512 bool get isEmpty => _tree._count == 0; |
513 Iterator<K> get iterator => new _SplayTreeKeyIterator<K>(_tree); | 513 Iterator<K> get iterator => new _SplayTreeKeyIterator<K>(_tree); |
514 } | 514 } |
515 | 515 |
516 class _SplayTreeValueIterable<K, V> extends Iterable<V> { | 516 class _SplayTreeValueIterable<K, V> extends IterableBase<V> { |
517 SplayTreeMap<K, V> _map; | 517 SplayTreeMap<K, V> _map; |
518 _SplayTreeValueIterable(this._map); | 518 _SplayTreeValueIterable(this._map); |
519 int get length => _map._count; | 519 int get length => _map._count; |
520 bool get isEmpty => _map._count == 0; | 520 bool get isEmpty => _map._count == 0; |
521 Iterator<V> get iterator => new _SplayTreeValueIterator<K, V>(_map); | 521 Iterator<V> get iterator => new _SplayTreeValueIterator<K, V>(_map); |
522 } | 522 } |
523 | 523 |
524 class _SplayTreeKeyIterator<K> extends _SplayTreeIterator<K> { | 524 class _SplayTreeKeyIterator<K> extends _SplayTreeIterator<K> { |
525 _SplayTreeKeyIterator(_SplayTree<K> map): super(map); | 525 _SplayTreeKeyIterator(_SplayTree<K> map): super(map); |
526 K _getValue(_SplayTreeNode node) => node.key; | 526 K _getValue(_SplayTreeNode node) => node.key; |
527 } | 527 } |
528 | 528 |
529 class _SplayTreeValueIterator<K, V> extends _SplayTreeIterator<V> { | 529 class _SplayTreeValueIterator<K, V> extends _SplayTreeIterator<V> { |
530 _SplayTreeValueIterator(SplayTreeMap<K, V> map): super(map); | 530 _SplayTreeValueIterator(SplayTreeMap<K, V> map): super(map); |
531 V _getValue(_SplayTreeMapNode node) => node.value; | 531 V _getValue(_SplayTreeMapNode node) => node.value; |
532 } | 532 } |
533 | 533 |
534 class _SplayTreeNodeIterator<K> | 534 class _SplayTreeNodeIterator<K> |
535 extends _SplayTreeIterator<_SplayTreeNode<K>> { | 535 extends _SplayTreeIterator<_SplayTreeNode<K>> { |
536 _SplayTreeNodeIterator(_SplayTree<K> map): super(map); | 536 _SplayTreeNodeIterator(_SplayTree<K> map): super(map); |
537 _SplayTreeNode<K> _getValue(_SplayTreeNode node) => node; | 537 _SplayTreeNode<K> _getValue(_SplayTreeNode node) => node; |
538 } | 538 } |
OLD | NEW |