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

Side by Side Diff: sdk/lib/internal/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 5 years, 12 months 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/html/html_common/filtered_element_list.dart ('k') | tests/co19/co19-co19.status » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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._internal; 5 part of dart._internal;
6 6
7 /** 7 /**
8 * Marker interface for [Iterable] subclasses that have an efficient 8 * Marker interface for [Iterable] subclasses that have an efficient
9 * [length] implementation. 9 * [length] implementation.
10 */ 10 */
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 int length = this.length; 87 int length = this.length;
88 for (int i = 0; i < length; i++) { 88 for (int i = 0; i < length; i++) {
89 if (test(elementAt(i))) return true; 89 if (test(elementAt(i))) return true;
90 if (length != this.length) { 90 if (length != this.length) {
91 throw new ConcurrentModificationError(this); 91 throw new ConcurrentModificationError(this);
92 } 92 }
93 } 93 }
94 return false; 94 return false;
95 } 95 }
96 96
97 dynamic firstWhere(bool test(E element), { Object orElse() }) { 97 E firstWhere(bool test(E element), { E orElse() }) {
98 int length = this.length; 98 int length = this.length;
99 for (int i = 0; i < length; i++) { 99 for (int i = 0; i < length; i++) {
100 E element = elementAt(i); 100 E element = elementAt(i);
101 if (test(element)) return element; 101 if (test(element)) return element;
102 if (length != this.length) { 102 if (length != this.length) {
103 throw new ConcurrentModificationError(this); 103 throw new ConcurrentModificationError(this);
104 } 104 }
105 } 105 }
106 if (orElse != null) return orElse(); 106 if (orElse != null) return orElse();
107 throw IterableElementError.noElement(); 107 throw IterableElementError.noElement();
108 } 108 }
109 109
110 dynamic lastWhere(bool test(E element), { Object orElse() }) { 110 E lastWhere(bool test(E element), { E orElse() }) {
111 int length = this.length; 111 int length = this.length;
112 for (int i = length - 1; i >= 0; i--) { 112 for (int i = length - 1; i >= 0; i--) {
113 E element = elementAt(i); 113 E element = elementAt(i);
114 if (test(element)) return element; 114 if (test(element)) return element;
115 if (length != this.length) { 115 if (length != this.length) {
116 throw new ConcurrentModificationError(this); 116 throw new ConcurrentModificationError(this);
117 } 117 }
118 } 118 }
119 if (orElse != null) return orElse(); 119 if (orElse != null) return orElse();
120 throw IterableElementError.noElement(); 120 throw IterableElementError.noElement();
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 * Creates errors throw by [Iterable] when the element count is wrong. 1160 * Creates errors throw by [Iterable] when the element count is wrong.
1161 */ 1161 */
1162 abstract class IterableElementError { 1162 abstract class IterableElementError {
1163 /** Error thrown thrown by, e.g., [Iterable.first] when there is no result. */ 1163 /** Error thrown thrown by, e.g., [Iterable.first] when there is no result. */
1164 static StateError noElement() => new StateError("No element"); 1164 static StateError noElement() => new StateError("No element");
1165 /** Error thrown by, e.g., [Iterable.single] if there are too many results. */ 1165 /** Error thrown by, e.g., [Iterable.single] if there are too many results. */
1166 static StateError tooMany() => new StateError("Too many elements"); 1166 static StateError tooMany() => new StateError("Too many elements");
1167 /** Error thrown by, e.g., [List.setRange] if there are too few elements. */ 1167 /** Error thrown by, e.g., [List.setRange] if there are too few elements. */
1168 static StateError tooFew() => new StateError("Too few elements"); 1168 static StateError tooFew() => new StateError("Too few elements");
1169 } 1169 }
OLDNEW
« no previous file with comments | « sdk/lib/html/html_common/filtered_element_list.dart ('k') | tests/co19/co19-co19.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698