OLD | NEW |
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 _interceptors; | 5 part of _interceptors; |
6 | 6 |
7 /** | 7 /** |
8 * The interceptor class for [List]. The compiler recognizes this | 8 * The interceptor class for [List]. The compiler recognizes this |
9 * class as an interceptor, and changes references to [:this:] to | 9 * class as an interceptor, and changes references to [:this:] to |
10 * actually use the receiver of the method, which is generated as an extra | 10 * actually use the receiver of the method, which is generated as an extra |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 void remove(Object element) { | 45 void remove(Object element) { |
46 checkGrowable(this, 'remove'); | 46 checkGrowable(this, 'remove'); |
47 for (int i = 0; i < this.length; i++) { | 47 for (int i = 0; i < this.length; i++) { |
48 if (this[i] == element) { | 48 if (this[i] == element) { |
49 JS('var', r'#.splice(#, 1)', this, i); | 49 JS('var', r'#.splice(#, 1)', this, i); |
50 return; | 50 return; |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 void removeAll(Iterable elements) { | |
56 IterableMixinWorkaround.removeAllList(this, elements); | |
57 } | |
58 | |
59 void retainAll(Iterable elements) { | |
60 IterableMixinWorkaround.retainAll(this, elements); | |
61 } | |
62 | |
63 void removeWhere(bool test(E element)) { | 55 void removeWhere(bool test(E element)) { |
64 // This could, and should, be optimized. | 56 // This could, and should, be optimized. |
65 IterableMixinWorkaround.removeWhereList(this, test); | 57 IterableMixinWorkaround.removeWhereList(this, test); |
66 } | 58 } |
67 | 59 |
68 void retainWhere(bool test(E element)) { | 60 void retainWhere(bool test(E element)) { |
69 IterableMixinWorkaround.removeWhereList(this, | 61 IterableMixinWorkaround.removeWhereList(this, |
70 (E element) => !test(element)); | 62 (E element) => !test(element)); |
71 } | 63 } |
72 | 64 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 255 |
264 bool contains(E other) { | 256 bool contains(E other) { |
265 for (int i = 0; i < length; i++) { | 257 for (int i = 0; i < length; i++) { |
266 if (other == this[i]) return true; | 258 if (other == this[i]) return true; |
267 } | 259 } |
268 return false; | 260 return false; |
269 } | 261 } |
270 | 262 |
271 bool get isEmpty => length == 0; | 263 bool get isEmpty => length == 0; |
272 | 264 |
273 String toString() => Collections.collectionToString(this); | 265 String toString() => ToString.iterableToString(this); |
274 | 266 |
275 List<E> toList({ bool growable: true }) => | 267 List<E> toList({ bool growable: true }) => |
276 new List<E>.from(this, growable: growable); | 268 new List<E>.from(this, growable: growable); |
277 | 269 |
278 Set<E> toSet() => new Set<E>.from(this); | 270 Set<E> toSet() => new Set<E>.from(this); |
279 | 271 |
280 Iterator<E> get iterator => new ListIterator<E>(this); | 272 Iterator<E> get iterator => new ListIterator<E>(this); |
281 | 273 |
282 int get hashCode => Primitives.objectHashCode(this); | 274 int get hashCode => Primitives.objectHashCode(this); |
283 | 275 |
(...skipping 29 matching lines...) Expand all Loading... |
313 } | 305 } |
314 } | 306 } |
315 | 307 |
316 /** | 308 /** |
317 * Dummy subclasses that allow the backend to track more precise | 309 * Dummy subclasses that allow the backend to track more precise |
318 * information about arrays through their type. | 310 * information about arrays through their type. |
319 */ | 311 */ |
320 class JSMutableArray extends JSArray {} | 312 class JSMutableArray extends JSArray {} |
321 class JSFixedArray extends JSMutableArray {} | 313 class JSFixedArray extends JSMutableArray {} |
322 class JSExtendableArray extends JSMutableArray {} | 314 class JSExtendableArray extends JSMutableArray {} |
OLD | NEW |