Chromium Code Reviews| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 * | 220 * |
| 221 * The map is based on a self-balancing binary tree. It allows most operations | 221 * The map is based on a self-balancing binary tree. It allows most operations |
| 222 * in amortized logarithmic time. | 222 * in amortized logarithmic time. |
| 223 * | 223 * |
| 224 * Keys of the map are compared using the `compare` function passed in | 224 * Keys of the map are compared using the `compare` function passed in |
| 225 * the constructor. If that is omitted, the objects are assumed to be | 225 * the constructor. If that is omitted, the objects are assumed to be |
| 226 * [Comparable], and are compared using their [Comparable.compareTo] | 226 * [Comparable], and are compared using their [Comparable.compareTo] |
| 227 * method. | 227 * method. |
| 228 */ | 228 */ |
| 229 class SplayTreeMap<K, V> extends _SplayTree<K> implements Map<K, V> { | 229 class SplayTreeMap<K, V> extends _SplayTree<K> implements Map<K, V> { |
| 230 Comparator<K> _comparator; | 230 Function /* TODO(dart2js-team): re-enable Comparator<K> */_comparator; |
|
Lasse Reichstein Nielsen
2013/02/28 12:34:19
Is this the same problem as http://dartbug.com/773
ngeoffray
2013/02/28 12:37:09
Yes, same bug. Done.
| |
| 231 | 231 |
| 232 SplayTreeMap([int compare(K key1, K key2)]) | 232 SplayTreeMap([int compare(K key1, K key2)]) |
| 233 : _comparator = (compare == null) ? Comparable.compare : compare; | 233 : _comparator = (compare == null) ? Comparable.compare : compare; |
| 234 | 234 |
| 235 int _compare(K key1, K key2) => _comparator(key1, key2); | 235 int _compare(K key1, K key2) => _comparator(key1, key2); |
| 236 | 236 |
| 237 SplayTreeMap._internal(); | 237 SplayTreeMap._internal(); |
| 238 | 238 |
| 239 V operator [](K key) { | 239 V operator [](K key) { |
| 240 if (_root != null) { | 240 if (_root != null) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 class _SplayTreeValueIterator<K, V> extends _SplayTreeIterator<V> { | 491 class _SplayTreeValueIterator<K, V> extends _SplayTreeIterator<V> { |
| 492 _SplayTreeValueIterator(SplayTreeMap<K, V> map): super(map); | 492 _SplayTreeValueIterator(SplayTreeMap<K, V> map): super(map); |
| 493 V _getValue(_SplayTreeMapNode node) => node.value; | 493 V _getValue(_SplayTreeMapNode node) => node.value; |
| 494 } | 494 } |
| 495 | 495 |
| 496 class _SplayTreeNodeIterator<K> | 496 class _SplayTreeNodeIterator<K> |
| 497 extends _SplayTreeIterator<_SplayTreeNode<K>> { | 497 extends _SplayTreeIterator<_SplayTreeNode<K>> { |
| 498 _SplayTreeNodeIterator(_SplayTree<K> map): super(map); | 498 _SplayTreeNodeIterator(_SplayTree<K> map): super(map); |
| 499 _SplayTreeNode<K> _getValue(_SplayTreeNode node) => node; | 499 _SplayTreeNode<K> _getValue(_SplayTreeNode node) => node; |
| 500 } | 500 } |
| OLD | NEW |