OLD | NEW |
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 part of html_common; | 5 part of html_common; |
6 | 6 |
7 /** | 7 /** |
8 * An indexable collection of a node's descendants in the document tree, | 8 * An indexable collection of a node's descendants in the document tree, |
9 * filtered so that only elements are in the collection. | 9 * filtered so that only elements are in the collection. |
10 */ | 10 */ |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if (element is! Element) return; | 115 if (element is! Element) return; |
116 for (int i = 0; i < length; i++) { | 116 for (int i = 0; i < length; i++) { |
117 Element indexElement = this[i]; | 117 Element indexElement = this[i]; |
118 if (identical(indexElement, element)) { | 118 if (identical(indexElement, element)) { |
119 indexElement.remove(); | 119 indexElement.remove(); |
120 return; | 120 return; |
121 } | 121 } |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 // Operations defined in terms of [Collections]' [remove]. | |
126 | |
127 void removeAll(Iterable elements) { | |
128 // This should be optimized to not use [remove] directly. | |
129 IterableMixinWorkaround.removeAll(this, elements); | |
130 } | |
131 | |
132 void retainAll(Iterable elements) { | |
133 IterableMixinWorkaround.retainAll(this, elements); | |
134 } | |
135 | |
136 void removeWhere(bool test(Element element)) { | |
137 IterableMixinWorkaround.removeWhere(this, test); | |
138 } | |
139 | |
140 void retainWhere(bool test(Element element)) { | |
141 IterableMixinWorkaround.retainWhere(this, test); | |
142 } | |
143 | 125 |
144 Element reduce(Element combine(Element value, Element element)) { | 126 Element reduce(Element combine(Element value, Element element)) { |
145 return _filtered.reduce(combine); | 127 return _filtered.reduce(combine); |
146 } | 128 } |
147 | 129 |
148 dynamic fold(dynamic initialValue, | 130 dynamic fold(dynamic initialValue, |
149 dynamic combine(dynamic previousValue, Element element)) { | 131 dynamic combine(dynamic previousValue, Element element)) { |
150 return _filtered.fold(initialValue, combine); | 132 return _filtered.fold(initialValue, combine); |
151 } | 133 } |
152 | 134 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 Element get single => _filtered.single; | 192 Element get single => _filtered.single; |
211 | 193 |
212 Element min([int compare(Element a, Element b)]) => _filtered.min(compare); | 194 Element min([int compare(Element a, Element b)]) => _filtered.min(compare); |
213 | 195 |
214 Element max([int compare(Element a, Element b)]) => _filtered.max(compare); | 196 Element max([int compare(Element a, Element b)]) => _filtered.max(compare); |
215 | 197 |
216 Map<int, Element> asMap() { | 198 Map<int, Element> asMap() { |
217 return IterableMixinWorkaround.asMapList(this); | 199 return IterableMixinWorkaround.asMapList(this); |
218 } | 200 } |
219 } | 201 } |
OLD | NEW |