OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Patch file for dart:collection classes. | 5 // Patch file for dart:collection classes. |
6 import 'dart:_foreign_helper' show JS; | 6 import 'dart:_foreign_helper' show JS; |
7 import 'dart:_js_helper' show fillLiteralMap, NoInline, NoThrows, patch; | 7 import 'dart:_js_helper' show |
| 8 fillLiteralMap, InternalMap, NoInline, NoThrows, patch; |
8 | 9 |
9 @patch | 10 @patch |
10 class HashMap<K, V> { | 11 class HashMap<K, V> { |
11 @patch | 12 @patch |
12 factory HashMap({ bool equals(K key1, K key2), | 13 factory HashMap({ bool equals(K key1, K key2), |
13 int hashCode(K key), | 14 int hashCode(K key), |
14 bool isValidKey(potentialKey) }) { | 15 bool isValidKey(potentialKey) }) { |
15 if (isValidKey == null) { | 16 if (isValidKey == null) { |
16 if (hashCode == null) { | 17 if (hashCode == null) { |
17 if (equals == null) { | 18 if (equals == null) { |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 return fillLiteralMap(keyValuePairs, new _LinkedHashMap<K, V>()); | 523 return fillLiteralMap(keyValuePairs, new _LinkedHashMap<K, V>()); |
523 } | 524 } |
524 | 525 |
525 // Private factory constructor called by generated code for map literals. | 526 // Private factory constructor called by generated code for map literals. |
526 @NoThrows() @NoInline() | 527 @NoThrows() @NoInline() |
527 factory LinkedHashMap._empty() { | 528 factory LinkedHashMap._empty() { |
528 return new _LinkedHashMap<K, V>(); | 529 return new _LinkedHashMap<K, V>(); |
529 } | 530 } |
530 } | 531 } |
531 | 532 |
532 class _LinkedHashMap<K, V> implements LinkedHashMap<K, V> { | 533 class _LinkedHashMap<K, V> implements LinkedHashMap<K, V>, InternalMap { |
533 int _length = 0; | 534 int _length = 0; |
534 | 535 |
535 // The hash map contents are divided into three parts: one part for | 536 // The hash map contents are divided into three parts: one part for |
536 // string keys, one for numeric keys, and one for the rest. String | 537 // string keys, one for numeric keys, and one for the rest. String |
537 // and numeric keys map directly to their linked cells, but the rest | 538 // and numeric keys map directly to their linked cells, but the rest |
538 // of the entries are stored in bucket lists of the form: | 539 // of the entries are stored in bucket lists of the form: |
539 // | 540 // |
540 // [cell-0, cell-1, ...] | 541 // [cell-0, cell-1, ...] |
541 // | 542 // |
542 // where all keys in the same bucket share the same hash code. | 543 // where all keys in the same bucket share the same hash code. |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 } else if (_cell == null) { | 1829 } else if (_cell == null) { |
1829 _current = null; | 1830 _current = null; |
1830 return false; | 1831 return false; |
1831 } else { | 1832 } else { |
1832 _current = _cell._element; | 1833 _current = _cell._element; |
1833 _cell = _cell._next; | 1834 _cell = _cell._next; |
1834 return true; | 1835 return true; |
1835 } | 1836 } |
1836 } | 1837 } |
1837 } | 1838 } |
OLD | NEW |