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

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

Issue 2754013002: Format all dart: library files (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 * Such a map can be created directly using [LinkedHashMap.identity]. 63 * Such a map can be created directly using [LinkedHashMap.identity].
64 * 64 *
65 * The used `equals` and `hashCode` method should always be consistent, 65 * The used `equals` and `hashCode` method should always be consistent,
66 * so that if `equals(a, b)` then `hashCode(a) == hashCode(b)`. The hash 66 * so that if `equals(a, b)` then `hashCode(a) == hashCode(b)`. The hash
67 * of an object, or what it compares equal to, should not change while the 67 * of an object, or what it compares equal to, should not change while the
68 * object is in the table. If it does change, the result is unpredictable. 68 * object is in the table. If it does change, the result is unpredictable.
69 * 69 *
70 * If you supply one of [equals] and [hashCode], 70 * If you supply one of [equals] and [hashCode],
71 * you should generally also to supply the other. 71 * you should generally also to supply the other.
72 */ 72 */
73 external factory LinkedHashMap({bool equals(K key1, K key2), 73 external factory LinkedHashMap(
74 int hashCode(K key), 74 {bool equals(K key1, K key2),
75 bool isValidKey(potentialKey)}); 75 int hashCode(K key),
76 bool isValidKey(potentialKey)});
76 77
77 /** 78 /**
78 * Creates an insertion-ordered identity-based map. 79 * Creates an insertion-ordered identity-based map.
79 * 80 *
80 * Effectively a shorthand for: 81 * Effectively a shorthand for:
81 * 82 *
82 * new LinkedHashMap<K, V>(equals: identical, 83 * new LinkedHashMap<K, V>(equals: identical,
83 * hashCode: identityHashCode) 84 * hashCode: identityHashCode)
84 */ 85 */
85 external factory LinkedHashMap.identity(); 86 external factory LinkedHashMap.identity();
86 87
87 /** 88 /**
88 * Creates a [LinkedHashMap] that contains all key value pairs of [other]. 89 * Creates a [LinkedHashMap] that contains all key value pairs of [other].
89 */ 90 */
90 factory LinkedHashMap.from(Map other) { 91 factory LinkedHashMap.from(Map other) {
91 LinkedHashMap<K, V> result = new LinkedHashMap<K, V>(); 92 LinkedHashMap<K, V> result = new LinkedHashMap<K, V>();
92 other.forEach((k, v) { result[k as Object/*=K*/] = v as Object/*=V*/; }); 93 other.forEach((k, v) {
94 result[k as Object/*=K*/] = v as Object/*=V*/;
95 });
93 return result; 96 return result;
94 } 97 }
95 98
96 /** 99 /**
97 * Creates a [LinkedHashMap] where the keys and values are computed from the 100 * Creates a [LinkedHashMap] where the keys and values are computed from the
98 * [iterable]. 101 * [iterable].
99 * 102 *
100 * For each element of the [iterable] this constructor computes a key/value 103 * For each element of the [iterable] this constructor computes a key/value
101 * pair, by applying [key] and [value] respectively. 104 * pair, by applying [key] and [value] respectively.
102 * 105 *
(...skipping 20 matching lines...) Expand all
123 * overwrites the previous value. 126 * overwrites the previous value.
124 * 127 *
125 * It is an error if the two [Iterable]s don't have the same length. 128 * It is an error if the two [Iterable]s don't have the same length.
126 */ 129 */
127 factory LinkedHashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { 130 factory LinkedHashMap.fromIterables(Iterable<K> keys, Iterable<V> values) {
128 LinkedHashMap<K, V> map = new LinkedHashMap<K, V>(); 131 LinkedHashMap<K, V> map = new LinkedHashMap<K, V>();
129 Maps._fillMapWithIterables(map, keys, values); 132 Maps._fillMapWithIterables(map, keys, values);
130 return map; 133 return map;
131 } 134 }
132 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698