| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart.collection; | 5 part of dart.collection; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Abstract implementation of a list. | 8 * Abstract implementation of a list. |
| 9 * | 9 * |
| 10 * All operations are defined in terms of `length`, `operator[]`, | 10 * All operations are defined in terms of `length`, `operator[]`, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 void remove(Object element) { | 242 void remove(Object element) { |
| 243 for (int i = 0; i < this.length; i++) { | 243 for (int i = 0; i < this.length; i++) { |
| 244 if (this[i] == element) { | 244 if (this[i] == element) { |
| 245 this.setRange(i, this.length - i - 1, this, i + 1); | 245 this.setRange(i, this.length - i - 1, this, i + 1); |
| 246 this.length -= 1; | 246 this.length -= 1; |
| 247 return; | 247 return; |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 void removeAll(Iterable<Object> elements) { | |
| 253 if (elements is! Set) { | |
| 254 elements = elements.toSet(); | |
| 255 } | |
| 256 _filter(this, elements.contains, false); | |
| 257 } | |
| 258 | |
| 259 | |
| 260 void retainAll(Iterable<E> elements) { | |
| 261 if (elements is! Set) { | |
| 262 elements = elements.toSet(); | |
| 263 } | |
| 264 _filter(this, elements.contains, true); | |
| 265 } | |
| 266 | |
| 267 void removeWhere(bool test(E element)) { | 252 void removeWhere(bool test(E element)) { |
| 268 _filter(this, test, false); | 253 _filter(this, test, false); |
| 269 } | 254 } |
| 270 | 255 |
| 271 void retainWhere(bool test(E element)) { | 256 void retainWhere(bool test(E element)) { |
| 272 _filter(this, test, true); | 257 _filter(this, test, true); |
| 273 } | 258 } |
| 274 | 259 |
| 275 static void _filter(List source, | 260 static void _filter(List source, |
| 276 bool test(var element), | 261 bool test(var element), |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 for (int i = startIndex; i >= 0; i--) { | 416 for (int i = startIndex; i >= 0; i--) { |
| 432 if (this[i] == element) { | 417 if (this[i] == element) { |
| 433 return i; | 418 return i; |
| 434 } | 419 } |
| 435 } | 420 } |
| 436 return -1; | 421 return -1; |
| 437 } | 422 } |
| 438 | 423 |
| 439 Iterable<E> get reversed => new ReversedListIterable(this); | 424 Iterable<E> get reversed => new ReversedListIterable(this); |
| 440 } | 425 } |
| OLD | NEW |