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

Side by Side Diff: tools/dom/src/CssClassSet.dart

Issue 14071002: Added new version of reduce. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed more uses of max, and a few bugs. Created 7 years, 8 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
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 html; 5 part of html;
6 6
7 abstract class CssClassSet implements Set<String> { 7 abstract class CssClassSet implements Set<String> {
8 8
9 String toString() { 9 String toString() {
10 return readClasses().join(' '); 10 return readClasses().join(' ');
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 Iterable expand(Iterable f(String element)) => readClasses().expand(f); 51 Iterable expand(Iterable f(String element)) => readClasses().expand(f);
52 52
53 bool every(bool f(String element)) => readClasses().every(f); 53 bool every(bool f(String element)) => readClasses().every(f);
54 54
55 bool any(bool f(String element)) => readClasses().any(f); 55 bool any(bool f(String element)) => readClasses().any(f);
56 56
57 bool get isEmpty => readClasses().isEmpty; 57 bool get isEmpty => readClasses().isEmpty;
58 58
59 int get length => readClasses().length; 59 int get length => readClasses().length;
60 60
61 dynamic reduce(dynamic initialValue, 61 String reduce(String combine(String value, String element)) {
62 dynamic combine(dynamic previousValue, String element)) { 62 return readClasses().reduce(combine);
63 return readClasses().reduce(initialValue, combine);
64 } 63 }
65 64
66 dynamic fold(dynamic initialValue, 65 dynamic fold(dynamic initialValue,
67 dynamic combine(dynamic previousValue, String element)) { 66 dynamic combine(dynamic previousValue, String element)) {
68 return readClasses().fold(initialValue, combine); 67 return readClasses().fold(initialValue, combine);
69 } 68 }
70 // interface Collection - END 69 // interface Collection - END
71 70
72 // interface Set - BEGIN 71 // interface Set - BEGIN
73 /** 72 /**
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 162
164 Set<String> difference(Set<String> other) => 163 Set<String> difference(Set<String> other) =>
165 readClasses().difference(other); 164 readClasses().difference(other);
166 165
167 String get first => readClasses().first; 166 String get first => readClasses().first;
168 String get last => readClasses().last; 167 String get last => readClasses().last;
169 String get single => readClasses().single; 168 String get single => readClasses().single;
170 List<String> toList({ bool growable: true }) => 169 List<String> toList({ bool growable: true }) =>
171 readClasses().toList(growable: growable); 170 readClasses().toList(growable: growable);
172 Set<String> toSet() => readClasses().toSet(); 171 Set<String> toSet() => readClasses().toSet();
173 String min([int compare(String a, String b)]) =>
174 readClasses().min(compare);
175 String max([int compare(String a, String b)]) =>
176 readClasses().max(compare);
177 Iterable<String> take(int n) => readClasses().take(n); 172 Iterable<String> take(int n) => readClasses().take(n);
178 Iterable<String> takeWhile(bool test(String value)) => 173 Iterable<String> takeWhile(bool test(String value)) =>
179 readClasses().takeWhile(test); 174 readClasses().takeWhile(test);
180 Iterable<String> skip(int n) => readClasses().skip(n); 175 Iterable<String> skip(int n) => readClasses().skip(n);
181 Iterable<String> skipWhile(bool test(String value)) => 176 Iterable<String> skipWhile(bool test(String value)) =>
182 readClasses().skipWhile(test); 177 readClasses().skipWhile(test);
183 String firstWhere(bool test(String value), { String orElse() }) => 178 String firstWhere(bool test(String value), { String orElse() }) =>
184 readClasses().firstWhere(test, orElse: orElse); 179 readClasses().firstWhere(test, orElse: orElse);
185 String lastWhere(bool test(String value), {String orElse()}) => 180 String lastWhere(bool test(String value), {String orElse()}) =>
186 readClasses().lastWhere(test, orElse: orElse); 181 readClasses().lastWhere(test, orElse: orElse);
(...skipping 28 matching lines...) Expand all
215 */ 210 */
216 Set<String> readClasses(); 211 Set<String> readClasses();
217 212
218 /** 213 /**
219 * Join all the elements of a set into one string and write 214 * Join all the elements of a set into one string and write
220 * back to the element. 215 * back to the element.
221 * This is intended to be overridden by specific implementations. 216 * This is intended to be overridden by specific implementations.
222 */ 217 */
223 void writeClasses(Set<String> s); 218 void writeClasses(Set<String> s);
224 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698