Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: sdk/lib/core/iterable.dart

Issue 745573002: Create generic check methods for RangeError causing checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix long line Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/errors.dart ('k') | sdk/lib/core/string.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/iterable.dart
diff --git a/sdk/lib/core/iterable.dart b/sdk/lib/core/iterable.dart
index a6bf3e92eb55de094879047904c82c1dd6b0b037..7f2c5d6ec93331b2bff02df5ce815d5d64e13611 100644
--- a/sdk/lib/core/iterable.dart
+++ b/sdk/lib/core/iterable.dart
@@ -201,14 +201,14 @@ abstract class Iterable<E> {
bool get isNotEmpty;
/**
- * Returns an [Iterable] with at most [n] elements.
+ * Returns an [Iterable] with at most [count] elements.
*
- * The returned [Iterable] may contain fewer than [n] elements, if `this`
- * contains fewer than [n] elements.
+ * The returned `Iterable` may contain fewer than `count` elements, if `this`
+ * contains fewer than `count` elements.
*
- * It is an error if [n] is negative.
+ * It is an error if `count` is negative.
*/
- Iterable<E> take(int n);
+ Iterable<E> take(int count);
/**
* Returns an Iterable that stops once [test] is not satisfied anymore.
@@ -223,14 +223,14 @@ abstract class Iterable<E> {
Iterable<E> takeWhile(bool test(E value));
/**
- * Returns an Iterable that skips the first [n] elements.
+ * Returns an Iterable that skips the first [count] elements.
*
- * If `this` has fewer than [n] elements, then the resulting Iterable is
+ * If `this` has fewer than `count` elements, then the resulting Iterable is
* empty.
*
- * It is an error if [n] is negative.
+ * It is an error if `count` is negative.
*/
- Iterable<E> skip(int n);
+ Iterable<E> skip(int count);
/**
* Returns an Iterable that skips elements while [test] is satisfied.
@@ -321,18 +321,18 @@ class _GeneratorIterable<E> extends IterableBase<E>
new _GeneratorIterator<E>(_start, _end, _generator);
int get length => _end - _start;
- Iterable<E> skip(int n) {
- if (n < 0) throw new RangeError.value(n);
- if (n == 0) return this;
- int newStart = _start + n;
+ Iterable<E> skip(int count) {
+ RangeError.checkNotNegative(count, "count");
+ if (count == 0) return this;
+ int newStart = _start + count;
if (newStart >= _end) return new EmptyIterable<E>();
return new _GeneratorIterable<E>.slice(newStart, _end, _generator);
}
- Iterable<E> take(int n) {
- if (n < 0) throw new RangeError.value(n);
- if (n == 0) return new EmptyIterable<E>();
- int newEnd = _start + n;
+ Iterable<E> take(int count) {
+ RangeError.checkNotNegative(count, "count");
+ if (count == 0) return new EmptyIterable<E>();
+ int newEnd = _start + count;
if (newEnd >= _end) return this;
return new _GeneratorIterable<E>.slice(_start, newEnd, _generator);
}
« no previous file with comments | « sdk/lib/core/errors.dart ('k') | sdk/lib/core/string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698