Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // -- start List<$E> mixins. | 1 // -- start List<$E> mixins. |
| 2 // $E is the element type. | 2 // $E is the element type. |
| 3 | 3 |
| 4 // From Iterable<$E>: | 4 // From Iterable<$E>: |
| 5 | 5 |
| 6 Iterator<$E> get iterator { | 6 Iterator<$E> get iterator { |
| 7 // Note: NodeLists are not fixed size. And most probably length shouldn't | 7 // Note: NodeLists are not fixed size. And most probably length shouldn't |
| 8 // be cached in both iterator _and_ forEach method. For now caching it | 8 // be cached in both iterator _and_ forEach method. For now caching it |
| 9 // for consistency. | 9 // for consistency. |
| 10 return new FixedSizeListIterator<$E>(this); | 10 return new FixedSizeListIterator<$E>(this); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 bool contains($E element) => IterableMixinWorkaround.contains(this, element); | 22 bool contains($E element) => IterableMixinWorkaround.contains(this, element); |
| 23 $else | 23 $else |
| 24 // contains() defined by IDL. | 24 // contains() defined by IDL. |
| 25 $endif | 25 $endif |
| 26 | 26 |
| 27 void forEach(void f($E element)) => IterableMixinWorkaround.forEach(this, f); | 27 void forEach(void f($E element)) => IterableMixinWorkaround.forEach(this, f); |
| 28 | 28 |
| 29 String join([String separator]) => | 29 String join([String separator]) => |
| 30 IterableMixinWorkaround.joinList(this, separator); | 30 IterableMixinWorkaround.joinList(this, separator); |
| 31 | 31 |
| 32 List mappedBy(f($E element)) => IterableMixinWorkaround.mappedByList(this, f); | 32 Iterable map(f($E element)) => |
|
floitsch
2013/01/30 14:48:44
should return an iterable.
Lasse Reichstein Nielsen
2013/01/31 11:33:49
Done.
| |
| 33 IterableMixinWorkaround.mappedByList(this, f); | |
| 34 | |
| 35 Iterable mappedBy(f($E element)) => map(f); | |
| 33 | 36 |
| 34 Iterable<$E> where(bool f($E element)) => | 37 Iterable<$E> where(bool f($E element)) => |
| 35 IterableMixinWorkaround.where(this, f); | 38 IterableMixinWorkaround.where(this, f); |
| 36 | 39 |
| 37 bool every(bool f($E element)) => IterableMixinWorkaround.every(this, f); | 40 bool every(bool f($E element)) => IterableMixinWorkaround.every(this, f); |
| 38 | 41 |
| 39 bool any(bool f($E element)) => IterableMixinWorkaround.any(this, f); | 42 bool any(bool f($E element)) => IterableMixinWorkaround.any(this, f); |
| 40 | 43 |
| 41 List<$E> toList() => new List<$E>.from(this); | 44 List<$E> toList() => new List<$E>.from(this); |
| 42 Set<$E> toSet() => new Set<$E>.from(this); | 45 Set<$E> toSet() => new Set<$E>.from(this); |
| 43 | 46 |
| 44 bool get isEmpty => this.length == 0; | 47 bool get isEmpty => this.length == 0; |
| 45 | 48 |
| 46 List<$E> take(int n) => IterableMixinWorkaround.takeList(this, n); | 49 Iterable<$E> take(int n) => IterableMixinWorkaround.takeList(this, n); |
| 47 | 50 |
| 48 Iterable<$E> takeWhile(bool test($E value)) { | 51 Iterable<$E> takeWhile(bool test($E value)) { |
| 49 return IterableMixinWorkaround.takeWhile(this, test); | 52 return IterableMixinWorkaround.takeWhile(this, test); |
| 50 } | 53 } |
| 51 | 54 |
| 52 List<$E> skip(int n) => IterableMixinWorkaround.skipList(this, n); | 55 Iterable<$E> skip(int n) => IterableMixinWorkaround.skipList(this, n); |
| 53 | 56 |
| 54 Iterable<$E> skipWhile(bool test($E value)) { | 57 Iterable<$E> skipWhile(bool test($E value)) { |
| 55 return IterableMixinWorkaround.skipWhile(this, test); | 58 return IterableMixinWorkaround.skipWhile(this, test); |
| 56 } | 59 } |
| 57 | 60 |
| 58 $E firstMatching(bool test($E value), { $E orElse() }) { | 61 $E firstMatching(bool test($E value), { $E orElse() }) { |
| 59 return IterableMixinWorkaround.firstMatching(this, test, orElse); | 62 return IterableMixinWorkaround.firstMatching(this, test, orElse); |
| 60 } | 63 } |
| 61 | 64 |
| 62 $E lastMatching(bool test($E value), {$E orElse()}) { | 65 $E lastMatching(bool test($E value), {$E orElse()}) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 } | 178 } |
| 176 | 179 |
| 177 void insertRange(int start, int rangeLength, [$E initialValue]) { | 180 void insertRange(int start, int rangeLength, [$E initialValue]) { |
| 178 throw new UnsupportedError("Cannot insertRange on immutable List."); | 181 throw new UnsupportedError("Cannot insertRange on immutable List."); |
| 179 } | 182 } |
| 180 | 183 |
| 181 List<$E> getRange(int start, int rangeLength) => | 184 List<$E> getRange(int start, int rangeLength) => |
| 182 Lists.getRange(this, start, rangeLength, <$E>[]); | 185 Lists.getRange(this, start, rangeLength, <$E>[]); |
| 183 | 186 |
| 184 // -- end List<$E> mixins. | 187 // -- end List<$E> mixins. |
| OLD | NEW |