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 /* | 7 /* |
8 * Helper class which implements complex [Map] operations | 8 * Helper class which implements complex [Map] operations |
9 * in term of basic ones ([Map.keys], [Map.operator []], | 9 * in term of basic ones ([Map.keys], [Map.operator []], |
10 * [Map.operator []=] and [Map.remove].) Not all methods are | 10 * [Map.operator []=] and [Map.remove].) Not all methods are |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 | 52 |
53 static Iterable getValues(Map map) { | 53 static Iterable getValues(Map map) { |
54 return map.keys.map((key) => map[key]); | 54 return map.keys.map((key) => map[key]); |
55 } | 55 } |
56 | 56 |
57 static int length(Map map) => map.keys.length; | 57 static int length(Map map) => map.keys.length; |
58 | 58 |
59 static bool isEmpty(Map map) => map.keys.isEmpty; | 59 static bool isEmpty(Map map) => map.keys.isEmpty; |
60 | 60 |
| 61 static bool isNotEmpty(Map map) => map.keys.isNotEmpty; |
| 62 |
61 /** | 63 /** |
62 * Returns a string representing the specified map. The returned string | 64 * Returns a string representing the specified map. The returned string |
63 * looks like this: [:'{key0: value0, key1: value1, ... keyN: valueN}':]. | 65 * looks like this: [:'{key0: value0, key1: value1, ... keyN: valueN}':]. |
64 * The value returned by its [toString] method is used to represent each | 66 * The value returned by its [toString] method is used to represent each |
65 * key or value. | 67 * key or value. |
66 * | 68 * |
67 * If the map collection contains a reference to itself, either | 69 * If the map collection contains a reference to itself, either |
68 * directly as a key or value, or indirectly through other collections | 70 * directly as a key or value, or indirectly through other collections |
69 * or maps, the contained reference is rendered as [:'{...}':]. This | 71 * or maps, the contained reference is rendered as [:'{...}':]. This |
70 * prevents the infinite regress that would otherwise occur. So, for example, | 72 * prevents the infinite regress that would otherwise occur. So, for example, |
71 * calling this method on a map whose sole entry maps the string key 'me' | 73 * calling this method on a map whose sole entry maps the string key 'me' |
72 * to a reference to the map would return [:'{me: {...}}':]. | 74 * to a reference to the map would return [:'{me: {...}}':]. |
73 * | 75 * |
74 * A typical implementation of a map's [toString] method will | 76 * A typical implementation of a map's [toString] method will |
75 * simply return the results of this method applied to the collection. | 77 * simply return the results of this method applied to the collection. |
76 */ | 78 */ |
77 static String mapToString(Map m) => ToString.mapToString(m); | 79 static String mapToString(Map m) => ToString.mapToString(m); |
78 } | 80 } |
OLD | NEW |