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

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

Issue 1127043002: Fix SplayTreeMap.from ignoring the compare and isValidKey arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/corelib/splay_tree_test.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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 | « no previous file | tests/corelib/splay_tree_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698