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 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 SplayTreeMap([int compare(K key1, K key2), bool isValidKey(potentialKey)]) | 267 SplayTreeMap([int compare(K key1, K key2), bool isValidKey(potentialKey)]) |
268 : _comparator = (compare == null) ? Comparable.compare : compare, | 268 : _comparator = (compare == null) ? Comparable.compare : compare, |
269 _validKey = (isValidKey != null) ? isValidKey : ((v) => v is K); | 269 _validKey = (isValidKey != null) ? isValidKey : ((v) => v is K); |
270 | 270 |
271 /** | 271 /** |
272 * Creates a [SplayTreeMap] that contains all key/value pairs of [other]. | 272 * Creates a [SplayTreeMap] that contains all key/value pairs of [other]. |
273 */ | 273 */ |
274 factory SplayTreeMap.from(Map other, | 274 factory SplayTreeMap.from(Map other, |
275 [int compare(K key1, K key2), | 275 [int compare(K key1, K key2), |
276 bool isValidKey(potentialKey)]) { | 276 bool isValidKey(potentialKey)]) { |
277 SplayTreeMap<K, V> result = new SplayTreeMap<K, V>(); | 277 SplayTreeMap<K, V> result = new SplayTreeMap<K, V>(compare, isValidKey); |
278 other.forEach((k, v) { result[k] = v; }); | 278 other.forEach((k, v) { result[k] = v; }); |
279 return result; | 279 return result; |
280 } | 280 } |
281 | 281 |
282 /** | 282 /** |
283 * Creates a [SplayTreeMap] where the keys and values are computed from the | 283 * Creates a [SplayTreeMap] where the keys and values are computed from the |
284 * [iterable]. | 284 * [iterable]. |
285 * | 285 * |
286 * For each element of the [iterable] this constructor computes a key/value | 286 * For each element of the [iterable] this constructor computes a key/value |
287 * pair, by applying [key] and [value] respectively. | 287 * pair, by applying [key] and [value] respectively. |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |