| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 264 } |
| 265 result = element; | 265 result = element; |
| 266 foundMatching = true; | 266 foundMatching = true; |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 if (foundMatching) return result; | 269 if (foundMatching) return result; |
| 270 throw IterableElementError.noElement(); | 270 throw IterableElementError.noElement(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 E elementAt(int index) { | 273 E elementAt(int index) { |
| 274 if (index is! int || index < 0) throw new RangeError.value(index); | 274 if (index is! int) throw new ArgumentError.notNull("index"); |
| 275 int remaining = index; | 275 RangeError.checkNotNegative(index, "index"); |
| 276 int elementIndex = 0; |
| 276 for (E element in this) { | 277 for (E element in this) { |
| 277 if (remaining == 0) return element; | 278 if (index == elementIndex) return element; |
| 278 remaining--; | 279 elementIndex++; |
| 279 } | 280 } |
| 280 throw new RangeError.value(index); | 281 throw new RangeError.index(index, this, "index", null, elementIndex); |
| 281 } | 282 } |
| 282 } | 283 } |
| 283 | 284 |
| 284 /** | 285 /** |
| 285 * Base implementation of [Set]. | 286 * Base implementation of [Set]. |
| 286 * | 287 * |
| 287 * This class provides a base implementation of a `Set` that depends only | 288 * This class provides a base implementation of a `Set` that depends only |
| 288 * on the abstract members: [add], [contains], [lookup], [remove], | 289 * on the abstract members: [add], [contains], [lookup], [remove], |
| 289 * [iterator], [length] and [toSet]. | 290 * [iterator], [length] and [toSet]. |
| 290 * | 291 * |
| (...skipping 10 matching lines...) Expand all Loading... |
| 301 abstract class SetBase<E> extends SetMixin<E> { | 302 abstract class SetBase<E> extends SetMixin<E> { |
| 302 /** | 303 /** |
| 303 * Convert a `Set` to a string as `{each, element, as, string}`. | 304 * Convert a `Set` to a string as `{each, element, as, string}`. |
| 304 * | 305 * |
| 305 * Handles circular references where converting one of the elements | 306 * Handles circular references where converting one of the elements |
| 306 * to a string ends up converting [set] to a string again. | 307 * to a string ends up converting [set] to a string again. |
| 307 */ | 308 */ |
| 308 static String setToString(Set set) => | 309 static String setToString(Set set) => |
| 309 IterableBase.iterableToFullString(set, '{', '}'); | 310 IterableBase.iterableToFullString(set, '{', '}'); |
| 310 } | 311 } |
| OLD | NEW |