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

Side by Side Diff: client/html/src/ElementWrappingImplementation.dart

Issue 9114021: Added method map to Collection interface and all its implementations (except classes generated fr... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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) 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 // TODO(jacobr): use Lists.dart to remove some of the duplicated functionality. 5 // TODO(jacobr): use Lists.dart to remove some of the duplicated functionality.
6 class _ChildrenElementList implements ElementList { 6 class _ChildrenElementList implements ElementList {
7 // Raw Element. 7 // Raw Element.
8 final _element; 8 final _element;
9 final _childElements; 9 final _childElements;
10 10
(...skipping 12 matching lines...) Expand all
23 Element get first() { 23 Element get first() {
24 return LevelDom.wrapElement(_element.firstElementChild); 24 return LevelDom.wrapElement(_element.firstElementChild);
25 } 25 }
26 26
27 void forEach(void f(Element element)) { 27 void forEach(void f(Element element)) {
28 for (var element in _childElements) { 28 for (var element in _childElements) {
29 f(LevelDom.wrapElement(element)); 29 f(LevelDom.wrapElement(element));
30 } 30 }
31 } 31 }
32 32
33 Collection map(f(Element element)) {
34 List output = new List();
35 forEach((Element element) {
36 output.add(f(element));
37 });
38 return output;
39 }
40
33 Collection<Element> filter(bool f(Element element)) { 41 Collection<Element> filter(bool f(Element element)) {
34 List<Element> output = new List<Element>(); 42 List<Element> output = new List<Element>();
35 forEach((Element element) { 43 forEach((Element element) {
36 if (f(element)) { 44 if (f(element)) {
37 output.add(element); 45 output.add(element);
38 } 46 }
39 }); 47 });
40 return output; 48 return output;
41 } 49 }
42 50
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return this[0]; 162 return this[0];
155 } 163 }
156 164
157 void forEach(void f(Element element)) { 165 void forEach(void f(Element element)) {
158 final length = _ptr.length; 166 final length = _ptr.length;
159 for (var i = 0; i < length; i++) { 167 for (var i = 0; i < length; i++) {
160 f(LevelDom.wrapElement(_ptr[i])); 168 f(LevelDom.wrapElement(_ptr[i]));
161 } 169 }
162 } 170 }
163 171
172 Collection map(f(Element element)) {
173 //TODO(jacobr): Implement this.
174 throw 'Not implemented yet.';
175 }
176
164 Collection<Element> filter(bool f(Element element)) { 177 Collection<Element> filter(bool f(Element element)) {
165 throw 'Not impl yet. todo(jacobr)'; 178 //TODO(jacobr): Implement this.
179 throw 'Not implemented yet.';
166 } 180 }
167 181
168 bool every(bool f(Element element)) { 182 bool every(bool f(Element element)) {
169 throw 'Not impl yet. todo(jacobr)'; 183 //TODO(jacobr): Implement this.
184 throw 'Not implemented yet.';
170 } 185 }
171 186
172 bool some(bool f(Element element)) { 187 bool some(bool f(Element element)) {
173 throw 'Not impl yet. todo(jacobr)'; 188 throw 'Not impl yet. todo(jacobr)';
174 } 189 }
175 190
176 bool isEmpty() { 191 bool isEmpty() {
177 return _ptr.length == 0; 192 return _ptr.length == 0;
178 } 193 }
179 194
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 776
762 ElementEvents get on() { 777 ElementEvents get on() {
763 if (_on === null) { 778 if (_on === null) {
764 _on = new ElementEventsImplementation._wrap(_ptr); 779 _on = new ElementEventsImplementation._wrap(_ptr);
765 } 780 }
766 return _on; 781 return _on;
767 } 782 }
768 783
769 Element clone(bool deep) => super.clone(deep); 784 Element clone(bool deep) => super.clone(deep);
770 } 785 }
OLDNEW
« no previous file with comments | « client/html/src/DocumentFragmentWrappingImplementation.dart ('k') | client/html/src/NodeWrappingImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698