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

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

Issue 1462743002: add generic method comments to a few SDK methods (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 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`.
11 */ 11 */
12 abstract class IterableMixin<E> implements Iterable<E> { 12 abstract class IterableMixin<E> implements Iterable<E> {
13 // This class has methods copied verbatim into: 13 // This class has methods copied verbatim into:
14 // - IterableBase 14 // - IterableBase
15 // - SetMixin 15 // - SetMixin
16 // If changing a method here, also change the other copies. 16 // If changing a method here, also change the other copies.
17 17
18 Iterable map(f(E element)) => new MappedIterable<E, dynamic>(this, f); 18 Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(E element)) =>
19 new MappedIterable<E, dynamic/*=T*/>(this, f);
19 20
20 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); 21 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f);
21 22
22 Iterable expand(Iterable f(E element)) => 23 Iterable/*<T>*/ expand/*<T>*/(Iterable/*<T>*/ f(E element)) =>
23 new ExpandIterable<E, dynamic>(this, f); 24 new ExpandIterable<E, dynamic/*=T*/>(this, f);
24 25
25 bool contains(Object element) { 26 bool contains(Object element) {
26 for (E e in this) { 27 for (E e in this) {
27 if (e == element) return true; 28 if (e == element) return true;
28 } 29 }
29 return false; 30 return false;
30 } 31 }
31 32
32 void forEach(void f(E element)) { 33 void forEach(void f(E element)) {
33 for (E element in this) f(element); 34 for (E element in this) f(element);
34 } 35 }
35 36
36 E reduce(E combine(E value, E element)) { 37 E reduce(E combine(E value, E element)) {
37 Iterator<E> iterator = this.iterator; 38 Iterator<E> iterator = this.iterator;
38 if (!iterator.moveNext()) { 39 if (!iterator.moveNext()) {
39 throw IterableElementError.noElement(); 40 throw IterableElementError.noElement();
40 } 41 }
41 E value = iterator.current; 42 E value = iterator.current;
42 while (iterator.moveNext()) { 43 while (iterator.moveNext()) {
43 value = combine(value, iterator.current); 44 value = combine(value, iterator.current);
44 } 45 }
45 return value; 46 return value;
46 } 47 }
47 48
48 dynamic fold(var initialValue, 49 dynamic/*=T*/ fold/*<T>*/(var/*=T*/ initialValue,
49 dynamic combine(var previousValue, E element)) { 50 dynamic/*=T*/ combine(var/*=T*/ previousValue, E element)) {
50 var value = initialValue; 51 var value = initialValue;
51 for (E element in this) value = combine(value, element); 52 for (E element in this) value = combine(value, element);
52 return value; 53 return value;
53 } 54 }
54 55
55 bool every(bool f(E element)) { 56 bool every(bool f(E element)) {
56 for (E element in this) { 57 for (E element in this) {
57 if (!f(element)) return false; 58 if (!f(element)) return false;
58 } 59 }
59 return true; 60 return true;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 elision = "..."; 391 elision = "...";
391 length += ELLIPSIS_SIZE + OVERHEAD; 392 length += ELLIPSIS_SIZE + OVERHEAD;
392 } 393 }
393 } 394 }
394 if (elision != null) { 395 if (elision != null) {
395 parts.add(elision); 396 parts.add(elision);
396 } 397 }
397 parts.add(penultimateString); 398 parts.add(penultimateString);
398 parts.add(ultimateString); 399 parts.add(ultimateString);
399 } 400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698