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

Side by Side Diff: sdk/lib/collection/iterable.dart

Issue 794953002: Fix a couple type bugs in dart html and what seems like strange type choices in dart:core (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_array.dart ('k') | sdk/lib/collection/list.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart.collection; 5 part of dart.collection;
6 6
7 /** 7 /**
8 * This [Iterable] mixin implements all [Iterable] members except `iterator`. 8 * This [Iterable] mixin implements all [Iterable] members except `iterator`.
9 * 9 *
10 * All other methods are implemented in terms of `iterator`. 10 * All other methods are implemented in terms of `iterator`.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 141
142 E get single { 142 E get single {
143 Iterator it = iterator; 143 Iterator it = iterator;
144 if (!it.moveNext()) throw IterableElementError.noElement(); 144 if (!it.moveNext()) throw IterableElementError.noElement();
145 E result = it.current; 145 E result = it.current;
146 if (it.moveNext()) throw IterableElementError.tooMany(); 146 if (it.moveNext()) throw IterableElementError.tooMany();
147 return result; 147 return result;
148 } 148 }
149 149
150 dynamic firstWhere(bool test(E value), { Object orElse() }) { 150 E firstWhere(bool test(E value), { E orElse() }) {
151 for (E element in this) { 151 for (E element in this) {
152 if (test(element)) return element; 152 if (test(element)) return element;
153 } 153 }
154 if (orElse != null) return orElse(); 154 if (orElse != null) return orElse();
155 throw IterableElementError.noElement(); 155 throw IterableElementError.noElement();
156 } 156 }
157 157
158 dynamic lastWhere(bool test(E value), { Object orElse() }) { 158 E lastWhere(bool test(E value), { E orElse() }) {
159 E result = null; 159 E result = null;
160 bool foundMatching = false; 160 bool foundMatching = false;
161 for (E element in this) { 161 for (E element in this) {
162 if (test(element)) { 162 if (test(element)) {
163 result = element; 163 result = element;
164 foundMatching = true; 164 foundMatching = true;
165 } 165 }
166 } 166 }
167 if (foundMatching) return result; 167 if (foundMatching) return result;
168 if (orElse != null) return orElse(); 168 if (orElse != null) return orElse();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 336 }
337 337
338 E get single { 338 E get single {
339 Iterator it = iterator; 339 Iterator it = iterator;
340 if (!it.moveNext()) throw IterableElementError.noElement(); 340 if (!it.moveNext()) throw IterableElementError.noElement();
341 E result = it.current; 341 E result = it.current;
342 if (it.moveNext()) throw IterableElementError.tooMany(); 342 if (it.moveNext()) throw IterableElementError.tooMany();
343 return result; 343 return result;
344 } 344 }
345 345
346 dynamic firstWhere(bool test(E value), { Object orElse() }) { 346 E firstWhere(bool test(E value), { E orElse() }) {
347 for (E element in this) { 347 for (E element in this) {
348 if (test(element)) return element; 348 if (test(element)) return element;
349 } 349 }
350 if (orElse != null) return orElse(); 350 if (orElse != null) return orElse();
351 throw IterableElementError.noElement(); 351 throw IterableElementError.noElement();
352 } 352 }
353 353
354 dynamic lastWhere(bool test(E value), { Object orElse() }) { 354 E lastWhere(bool test(E value), { E orElse() }) {
355 E result = null; 355 E result = null;
356 bool foundMatching = false; 356 bool foundMatching = false;
357 for (E element in this) { 357 for (E element in this) {
358 if (test(element)) { 358 if (test(element)) {
359 result = element; 359 result = element;
360 foundMatching = true; 360 foundMatching = true;
361 } 361 }
362 } 362 }
363 if (foundMatching) return result; 363 if (foundMatching) return result;
364 if (orElse != null) return orElse(); 364 if (orElse != null) return orElse();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 length += ELLIPSIS_SIZE + OVERHEAD; 591 length += ELLIPSIS_SIZE + OVERHEAD;
592 } 592 }
593 } 593 }
594 if (elision != null) { 594 if (elision != null) {
595 parts.add(elision); 595 parts.add(elision);
596 } 596 }
597 parts.add(penultimateString); 597 parts.add(penultimateString);
598 parts.add(ultimateString); 598 parts.add(ultimateString);
599 } 599 }
600 } 600 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_array.dart ('k') | sdk/lib/collection/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698