| 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 part of dart.collection; | 5 part of dart.collection; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A hash-table based implementation of [Map]. | 8 * A hash-table based implementation of [Map]. |
| 9 * | 9 * |
| 10 * The insertion order of keys is remembered, | 10 * The insertion order of keys is remembered, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 * | 62 * |
| 63 * Effectively a shorthand for: | 63 * Effectively a shorthand for: |
| 64 * | 64 * |
| 65 * new LinkedHashMap(equals: identical, hashCode: identityHashCodeOf) | 65 * new LinkedHashMap(equals: identical, hashCode: identityHashCodeOf) |
| 66 */ | 66 */ |
| 67 external factory LinkedHashMap.identity(); | 67 external factory LinkedHashMap.identity(); |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Creates a [LinkedHashMap] that contains all key value pairs of [other]. | 70 * Creates a [LinkedHashMap] that contains all key value pairs of [other]. |
| 71 */ | 71 */ |
| 72 factory LinkedHashMap.from(Map<K, V> other) { | 72 factory LinkedHashMap.from(Map other) { |
| 73 return new LinkedHashMap<K, V>()..addAll(other); | 73 LinkedHashMap<K, V> result = new LinkedHashMap<K, V>(); |
| 74 other.forEach((k, v) { result[k] = v; }); |
| 75 return result; |
| 74 } | 76 } |
| 75 | 77 |
| 76 /** | 78 /** |
| 77 * Creates a [LinkedHashMap] where the keys and values are computed from the | 79 * Creates a [LinkedHashMap] where the keys and values are computed from the |
| 78 * [iterable]. | 80 * [iterable]. |
| 79 * | 81 * |
| 80 * For each element of the [iterable] this constructor computes a key/value | 82 * For each element of the [iterable] this constructor computes a key/value |
| 81 * pair, by applying [key] and [value] respectively. | 83 * pair, by applying [key] and [value] respectively. |
| 82 * | 84 * |
| 83 * The keys of the key/value pairs do not need to be unique. The last | 85 * The keys of the key/value pairs do not need to be unique. The last |
| (...skipping 19 matching lines...) Expand all Loading... |
| 103 * overwrites the previous value. | 105 * overwrites the previous value. |
| 104 * | 106 * |
| 105 * It is an error if the two [Iterable]s don't have the same length. | 107 * It is an error if the two [Iterable]s don't have the same length. |
| 106 */ | 108 */ |
| 107 factory LinkedHashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { | 109 factory LinkedHashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { |
| 108 LinkedHashMap<K, V> map = new LinkedHashMap<K, V>(); | 110 LinkedHashMap<K, V> map = new LinkedHashMap<K, V>(); |
| 109 Maps._fillMapWithIterables(map, keys, values); | 111 Maps._fillMapWithIterables(map, keys, values); |
| 110 return map; | 112 return map; |
| 111 } | 113 } |
| 112 } | 114 } |
| OLD | NEW |