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

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

Issue 16285004: Better documentation on Sets and Maps, and more. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Change to runtime string patch - always check index of contains method. Created 7 years, 6 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
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-based map that iterates keys and values in key insertion order. 8 * A hash-table based implementation of [Map].
9 *
10 * Keys insertion order is remembered, and keys are iterated in insertion order.
11 * Values are iterated in their corresponding key's order.
12 *
13 * The keys of a `HashMap` must have consistent [Object.operator==]
14 * and [Object.hashCode] implementations. This means that the `==` operator
15 * must define a stable equivalence relation on the keys (reflexive,
16 * anti-symmetric, trasitive, and consistent over time), and that `hashCode`
ngeoffray 2013/06/04 11:51:33 trasitive -> transitive
17 * must be the same for objects that are considered equal by `==`.
18 *
19 * The map allows `null` as an key.
ngeoffray 2013/06/04 11:51:33 an -> a
9 */ 20 */
10 class LinkedHashMap<K, V> implements Map<K, V> { 21 class LinkedHashMap<K, V> implements Map<K, V> {
11 external LinkedHashMap(); 22 external LinkedHashMap();
12 23
13 factory LinkedHashMap.from(Map<K, V> other) { 24 factory LinkedHashMap.from(Map<K, V> other) {
14 return new LinkedHashMap<K, V>()..addAll(other); 25 return new LinkedHashMap<K, V>()..addAll(other);
15 } 26 }
16 27
17 external bool containsKey(K key); 28 external bool containsKey(K key);
18 29
19 external bool containsValue(V value); 30 external bool containsValue(V value);
20 31
21 external void addAll(Map<K, V> other); 32 external void addAll(Map<K, V> other);
22 33
23 external V operator [](K key); 34 external V operator [](K key);
24 35
25 external void operator []=(K key, V value); 36 external void operator []=(K key, V value);
26 37
27 external V putIfAbsent(K key, V ifAbsent()); 38 external V putIfAbsent(K key, V ifAbsent());
28 39
29 external V remove(K key); 40 external V remove(K key);
30 41
31 external void clear(); 42 external void clear();
32 43
33 external void forEach(void action (K key, V value)); 44 external void forEach(void action (K key, V value));
34 45
46 /** The keys of the map, in insertion order. */
35 external Iterable<K> get keys; 47 external Iterable<K> get keys;
48 /** The values of the map, in the order of their corresponding [keys].*/
36 external Iterable<V> get values; 49 external Iterable<V> get values;
37 50
38 external int get length; 51 external int get length;
39 52
40 external bool get isEmpty; 53 external bool get isEmpty;
41 54
42 external bool get isNotEmpty; 55 external bool get isNotEmpty;
43 56
44 String toString() => Maps.mapToString(this); 57 String toString() => Maps.mapToString(this);
45 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698