| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 * Base implementations of [Set]. | 6 * Base implementations of [Set]. |
| 7 */ | 7 */ |
| 8 part of dart.collection; | 8 part of dart.collection; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 if (!it.moveNext()) { | 225 if (!it.moveNext()) { |
| 226 throw IterableElementError.noElement(); | 226 throw IterableElementError.noElement(); |
| 227 } | 227 } |
| 228 E result; | 228 E result; |
| 229 do { | 229 do { |
| 230 result = it.current; | 230 result = it.current; |
| 231 } while(it.moveNext()); | 231 } while(it.moveNext()); |
| 232 return result; | 232 return result; |
| 233 } | 233 } |
| 234 | 234 |
| 235 dynamic firstWhere(bool test(E value), { Object orElse() }) { | 235 E firstWhere(bool test(E value), { E orElse() }) { |
| 236 for (E element in this) { | 236 for (E element in this) { |
| 237 if (test(element)) return element; | 237 if (test(element)) return element; |
| 238 } | 238 } |
| 239 if (orElse != null) return orElse(); | 239 if (orElse != null) return orElse(); |
| 240 throw IterableElementError.noElement(); | 240 throw IterableElementError.noElement(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 dynamic lastWhere(bool test(E value), { Object orElse() }) { | 243 E lastWhere(bool test(E value), { E orElse() }) { |
| 244 E result = null; | 244 E result = null; |
| 245 bool foundMatching = false; | 245 bool foundMatching = false; |
| 246 for (E element in this) { | 246 for (E element in this) { |
| 247 if (test(element)) { | 247 if (test(element)) { |
| 248 result = element; | 248 result = element; |
| 249 foundMatching = true; | 249 foundMatching = true; |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 if (foundMatching) return result; | 252 if (foundMatching) return result; |
| 253 if (orElse != null) return orElse(); | 253 if (orElse != null) return orElse(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 abstract class SetBase<E> extends SetMixin<E> { | 302 abstract class SetBase<E> extends SetMixin<E> { |
| 303 /** | 303 /** |
| 304 * Convert a `Set` to a string as `{each, element, as, string}`. | 304 * Convert a `Set` to a string as `{each, element, as, string}`. |
| 305 * | 305 * |
| 306 * Handles circular references where converting one of the elements | 306 * Handles circular references where converting one of the elements |
| 307 * to a string ends up converting [set] to a string again. | 307 * to a string ends up converting [set] to a string again. |
| 308 */ | 308 */ |
| 309 static String setToString(Set set) => | 309 static String setToString(Set set) => |
| 310 IterableBase.iterableToFullString(set, '{', '}'); | 310 IterableBase.iterableToFullString(set, '{', '}'); |
| 311 } | 311 } |
| OLD | NEW |