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

Side by Side Diff: lib/html/templates/html/impl/impl_NodeList.darttemplate

Issue 11169004: Add "contains" method to Collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use generator for html. Created 8 years, 2 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 // TODO(nweiz): when all implementations we target have the same name for the 5 // TODO(nweiz): when all implementations we target have the same name for the
6 // coreimpl implementation of List<E>, extend that rather than wrapping. 6 // coreimpl implementation of List<E>, extend that rather than wrapping.
7 class _ListWrapper<E> implements List<E> { 7 class _ListWrapper<E> implements List<E> {
8 List _list; 8 List _list;
9 9
10 _ListWrapper(List this._list); 10 _ListWrapper(List this._list);
11 11
12 Iterator<E> iterator() => _list.iterator(); 12 Iterator<E> iterator() => _list.iterator();
13 13
14 bool contains(E element) => _list.contains(element);
15
14 void forEach(void f(E element)) => _list.forEach(f); 16 void forEach(void f(E element)) => _list.forEach(f);
15 17
16 Collection map(f(E element)) => _list.map(f); 18 Collection map(f(E element)) => _list.map(f);
17 19
18 List<E> filter(bool f(E element)) => _list.filter(f); 20 List<E> filter(bool f(E element)) => _list.filter(f);
19 21
20 bool every(bool f(E element)) => _list.every(f); 22 bool every(bool f(E element)) => _list.every(f);
21 23
22 bool some(bool f(E element)) => _list.some(f); 24 bool some(bool f(E element)) => _list.some(f);
23 25
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 121 }
120 122
121 void clear() { 123 void clear() {
122 _parent.text = ''; 124 _parent.text = '';
123 } 125 }
124 126
125 void operator []=(int index, _NodeImpl value) { 127 void operator []=(int index, _NodeImpl value) {
126 _parent.$dom_replaceChild(value, this[index]); 128 _parent.$dom_replaceChild(value, this[index]);
127 } 129 }
128 130
131 bool contains(Node element) => _Collections.contains(this, element);
132
129 void forEach(void f(Node element)) => _Collections.forEach(this, f); 133 void forEach(void f(Node element)) => _Collections.forEach(this, f);
130 134
131 Collection map(f(Node element)) => _Collections.map(this, [], f); 135 Collection map(f(Node element)) => _Collections.map(this, [], f);
132 136
133 Collection<Node> filter(bool f(Node element)) => 137 Collection<Node> filter(bool f(Node element)) =>
134 new _NodeListWrapper(_Collections.filter(this, <Node>[], f)); 138 new _NodeListWrapper(_Collections.filter(this, <Node>[], f));
135 139
136 bool every(bool f(Node element)) => _Collections.every(this, f); 140 bool every(bool f(Node element)) => _Collections.every(this, f);
137 141
138 bool some(bool f(Node element)) => _Collections.some(this, f); 142 bool some(bool f(Node element)) => _Collections.some(this, f);
(...skipping 25 matching lines...) Expand all
164 void insertRange(int start, int rangeLength, [Node initialValue]) { 168 void insertRange(int start, int rangeLength, [Node initialValue]) {
165 throw new UnsupportedOperationException("Cannot insertRange on immutable Lis t."); 169 throw new UnsupportedOperationException("Cannot insertRange on immutable Lis t.");
166 } 170 }
167 List<Node> getRange(int start, int rangeLength) => 171 List<Node> getRange(int start, int rangeLength) =>
168 new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[])); 172 new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[]));
169 173
170 // -- end List<Node> mixins. 174 // -- end List<Node> mixins.
171 175
172 $!MEMBERS 176 $!MEMBERS
173 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698