| 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 /** | 5 /** |
| 6 * The [Collections] class implements static methods useful when | 6 * The [Collections] class implements static methods useful when |
| 7 * writing a class that implements [Collection] and the [iterator] | 7 * writing a class that implements [Collection] and the [iterator] |
| 8 * method. | 8 * method. |
| 9 */ | 9 */ |
| 10 class Collections { | 10 class Collections { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 /** | 93 /** |
| 94 * Appends a string representing the specified collection to the specified | 94 * Appends a string representing the specified collection to the specified |
| 95 * string buffer. The string is formatted as per [collectionToString]. | 95 * string buffer. The string is formatted as per [collectionToString]. |
| 96 * The [:visiting:] list contains references to all of the enclosing | 96 * The [:visiting:] list contains references to all of the enclosing |
| 97 * collections and maps (which are currently in the process of being | 97 * collections and maps (which are currently in the process of being |
| 98 * emitted into [:result:]). The [:visiting:] parameter allows this method to | 98 * emitted into [:result:]). The [:visiting:] parameter allows this method to |
| 99 * generate a [:'[...]':] or [:'{...}':] where required. In other words, | 99 * generate a [:'[...]':] or [:'{...}':] where required. In other words, |
| 100 * it allows this method and [_emitMap] to identify recursive collections | 100 * it allows this method and [_emitMap] to identify recursive collections |
| 101 * and maps. | 101 * and maps. |
| 102 */ | 102 */ |
| 103 static void _emitCollection(Collection c, StringBuffer result, List visiting)
{ | 103 static void _emitCollection(Collection c, |
| 104 StringBuffer result, |
| 105 List visiting) { |
| 104 visiting.add(c); | 106 visiting.add(c); |
| 105 bool isList = c is List; | 107 bool isList = c is List; |
| 106 result.add(isList ? '[' : '{'); | 108 result.add(isList ? '[' : '{'); |
| 107 | 109 |
| 108 bool first = true; | 110 bool first = true; |
| 109 for (var e in c) { | 111 for (var e in c) { |
| 110 if (!first) { | 112 if (!first) { |
| 111 result.add(', '); | 113 result.add(', '); |
| 112 } | 114 } |
| 113 first = false; | 115 first = false; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 * Returns true if the specified collection contains the specified object | 155 * Returns true if the specified collection contains the specified object |
| 154 * reference. | 156 * reference. |
| 155 */ | 157 */ |
| 156 static _containsRef(Collection c, Object ref) { | 158 static _containsRef(Collection c, Object ref) { |
| 157 for (var e in c) { | 159 for (var e in c) { |
| 158 if (e === ref) return true; | 160 if (e === ref) return true; |
| 159 } | 161 } |
| 160 return false; | 162 return false; |
| 161 } | 163 } |
| 162 } | 164 } |
| OLD | NEW |