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

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

Issue 1937103002: Make dart:collection strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rebase Created 4 years, 7 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
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 Iterable<E> skip(int count) { 115 Iterable<E> skip(int count) {
116 return new SkipIterable<E>(this, count); 116 return new SkipIterable<E>(this, count);
117 } 117 }
118 118
119 Iterable<E> skipWhile(bool test(E value)) { 119 Iterable<E> skipWhile(bool test(E value)) {
120 return new SkipWhileIterable<E>(this, test); 120 return new SkipWhileIterable<E>(this, test);
121 } 121 }
122 122
123 E get first { 123 E get first {
124 Iterator it = iterator; 124 Iterator<E> it = iterator;
125 if (!it.moveNext()) { 125 if (!it.moveNext()) {
126 throw IterableElementError.noElement(); 126 throw IterableElementError.noElement();
127 } 127 }
128 return it.current; 128 return it.current;
129 } 129 }
130 130
131 E get last { 131 E get last {
132 Iterator it = iterator; 132 Iterator<E> it = iterator;
133 if (!it.moveNext()) { 133 if (!it.moveNext()) {
134 throw IterableElementError.noElement(); 134 throw IterableElementError.noElement();
135 } 135 }
136 E result; 136 E result;
137 do { 137 do {
138 result = it.current; 138 result = it.current;
139 } while(it.moveNext()); 139 } while(it.moveNext());
140 return result; 140 return result;
141 } 141 }
142 142
143 E get single { 143 E get single {
144 Iterator it = iterator; 144 Iterator<E> it = iterator;
145 if (!it.moveNext()) throw IterableElementError.noElement(); 145 if (!it.moveNext()) throw IterableElementError.noElement();
146 E result = it.current; 146 E result = it.current;
147 if (it.moveNext()) throw IterableElementError.tooMany(); 147 if (it.moveNext()) throw IterableElementError.tooMany();
148 return result; 148 return result;
149 } 149 }
150 150
151 E firstWhere(bool test(E value), { E orElse() }) { 151 E firstWhere(bool test(E value), { E orElse() }) {
152 for (E element in this) { 152 for (E element in this) {
153 if (test(element)) return element; 153 if (test(element)) return element;
154 } 154 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 elision = "..."; 391 elision = "...";
392 length += ELLIPSIS_SIZE + OVERHEAD; 392 length += ELLIPSIS_SIZE + OVERHEAD;
393 } 393 }
394 } 394 }
395 if (elision != null) { 395 if (elision != null) {
396 parts.add(elision); 396 parts.add(elision);
397 } 397 }
398 parts.add(penultimateString); 398 parts.add(penultimateString);
399 parts.add(ultimateString); 399 parts.add(ultimateString);
400 } 400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698