mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
4c20cedd30
Now that I'm able to open the entire SDK in VSC, I'm fixing some of the analysis issues in various files (carefully) without changing their meaning. In this case, I removed unnecessary imports from benchmarks. In regexp_benchmark I ignored one warning which likely would have changed the behavior of the code. BUG=https://github.com/dart-lang/sdk/issues/52419 Change-Id: I9a195a4e45121313bd9f065f2579a165c3fec05b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303901 Auto-Submit: Eric Seidel <eric@shorebird.dev> Reviewed-by: William Hesse <whesse@google.com> Commit-Queue: William Hesse <whesse@google.com>
24 lines
918 B
Dart
24 lines
918 B
Dart
/// Marker interface for [Iterable] subclasses that have an efficient
|
|
/// [length] implementation.
|
|
abstract class EfficientLengthIterable<T> extends Iterable<T> {
|
|
const EfficientLengthIterable();
|
|
|
|
/// Returns the number of elements in the iterable.
|
|
///
|
|
/// This is an efficient operation that doesn't require iterating through
|
|
/// the elements.
|
|
@override
|
|
int get length;
|
|
}
|
|
|
|
/// Creates errors throw by [Iterable] when the element count is wrong.
|
|
abstract class IterableElementError {
|
|
/// Error thrown by, e.g., [Iterable.first] when there is no result.
|
|
static StateError noElement() => StateError('No element');
|
|
|
|
/// Error thrown by, e.g., [Iterable.single] if there are too many results.
|
|
static StateError tooMany() => StateError('Too many elements');
|
|
|
|
/// Error thrown by, e.g., [List.setRange] if there are too few elements.
|
|
static StateError tooFew() => StateError('Too few elements');
|
|
}
|