| 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 27 matching lines...) Expand all Loading... |
| 38 return v; | 38 return v; |
| 39 } | 39 } |
| 40 | 40 |
| 41 static clear(Map map) { | 41 static clear(Map map) { |
| 42 for (final k in map.keys.toList()) { | 42 for (final k in map.keys.toList()) { |
| 43 map.remove(k); | 43 map.remove(k); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 static forEach(Map map, void f(key, value)) { | 47 static forEach(Map map, void f(key, value)) { |
| 48 map.keys.forEach(f); | 48 for (final k in map.keys) { |
| 49 f(k, map[k]); |
| 50 } |
| 49 } | 51 } |
| 50 | 52 |
| 51 static Iterable getValues(Map map) { | 53 static Iterable getValues(Map map) { |
| 52 return map.keys.mappedBy((key) => map[key]); | 54 return map.keys.mappedBy((key) => map[key]); |
| 53 } | 55 } |
| 54 | 56 |
| 55 static int length(Map map) => map.keys.length; | 57 static int length(Map map) => map.keys.length; |
| 56 | 58 |
| 57 static bool isEmpty(Map map) => map.keys.isEmpty; | 59 static bool isEmpty(Map map) => map.keys.isEmpty; |
| 58 | 60 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 first = false; | 102 first = false; |
| 101 Collections._emitObject(k, result, visiting); | 103 Collections._emitObject(k, result, visiting); |
| 102 result.add(': '); | 104 result.add(': '); |
| 103 Collections._emitObject(v, result, visiting); | 105 Collections._emitObject(v, result, visiting); |
| 104 }); | 106 }); |
| 105 | 107 |
| 106 result.add('}'); | 108 result.add('}'); |
| 107 visiting.removeLast(); | 109 visiting.removeLast(); |
| 108 } | 110 } |
| 109 } | 111 } |
| OLD | NEW |