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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 SplayTreeMap<K, V> map = new SplayTreeMap<K, V>(compare, isValidKey); | 318 SplayTreeMap<K, V> map = new SplayTreeMap<K, V>(compare, isValidKey); |
319 Maps._fillMapWithIterables(map, keys, values); | 319 Maps._fillMapWithIterables(map, keys, values); |
320 return map; | 320 return map; |
321 } | 321 } |
322 | 322 |
323 int _compare(K key1, K key2) => _comparator(key1, key2); | 323 int _compare(K key1, K key2) => _comparator(key1, key2); |
324 | 324 |
325 SplayTreeMap._internal(); | 325 SplayTreeMap._internal(); |
326 | 326 |
327 V operator [](Object key) { | 327 V operator [](Object key) { |
328 if (key == null) throw new ArgumentError(key); | |
329 if (!_validKey(key)) return null; | 328 if (!_validKey(key)) return null; |
330 if (_root != null) { | 329 if (_root != null) { |
331 int comp = _splay(key); | 330 int comp = _splay(key); |
332 if (comp == 0) { | 331 if (comp == 0) { |
333 _SplayTreeMapNode mapRoot = _root; | 332 _SplayTreeMapNode mapRoot = _root; |
334 return mapRoot.value; | 333 return mapRoot.value; |
335 } | 334 } |
336 } | 335 } |
337 return null; | 336 return null; |
338 } | 337 } |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 return new _SplayTreeNode<E>(node.key)..left = _copyNode(node.left) | 828 return new _SplayTreeNode<E>(node.key)..left = _copyNode(node.left) |
830 ..right = _copyNode(node.right); | 829 ..right = _copyNode(node.right); |
831 } | 830 } |
832 | 831 |
833 void clear() { _clear(); } | 832 void clear() { _clear(); } |
834 | 833 |
835 Set<E> toSet() => _clone(); | 834 Set<E> toSet() => _clone(); |
836 | 835 |
837 String toString() => IterableBase.iterableToFullString(this, '{', '}'); | 836 String toString() => IterableBase.iterableToFullString(this, '{', '}'); |
838 } | 837 } |
OLD | NEW |