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

Unified Diff: sdk/lib/collection/set.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/collection/queue.dart ('k') | sdk/lib/convert/ascii.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/set.dart
diff --git a/sdk/lib/collection/set.dart b/sdk/lib/collection/set.dart
index 906312adfed50af1f50d98ad0169f827638f010a..74707611a7bbe6ca32cb97947dbf28bfe0ccb247 100644
--- a/sdk/lib/collection/set.dart
+++ b/sdk/lib/collection/set.dart
@@ -271,13 +271,14 @@ abstract class SetMixin<E> implements Set<E> {
}
E elementAt(int index) {
- if (index is! int || index < 0) throw new RangeError.value(index);
- int remaining = index;
+ if (index is! int) throw new ArgumentError.notNull("index");
+ RangeError.checkNotNegative(index, "index");
+ int elementIndex = 0;
for (E element in this) {
- if (remaining == 0) return element;
- remaining--;
+ if (index == elementIndex) return element;
+ elementIndex++;
}
- throw new RangeError.value(index);
+ throw new RangeError.index(index, this, "index", null, elementIndex);
}
}
« no previous file with comments | « sdk/lib/collection/queue.dart ('k') | sdk/lib/convert/ascii.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698