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

Side by Side Diff: sdk/lib/collection/list.dart

Issue 14048002: Make the analyzer happy about collections. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload. Created 7 years, 8 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
« no previous file with comments | « sdk/lib/collection/hash_set.dart ('k') | sdk/lib/collection/splay_tree.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 285 }
286 286
287 void removeAll(Iterable<Object> elements) { 287 void removeAll(Iterable<Object> elements) {
288 if (elements is! Set) { 288 if (elements is! Set) {
289 elements = elements.toSet(); 289 elements = elements.toSet();
290 } 290 }
291 _filter(this, elements.contains, false); 291 _filter(this, elements.contains, false);
292 } 292 }
293 293
294 294
295 void retainAll(Iterable<E> iterable) { 295 void retainAll(Iterable<E> elements) {
296 if (elements is! Set) { 296 if (elements is! Set) {
297 elements = elements.toSet(); 297 elements = elements.toSet();
298 } 298 }
299 _filter(this, elements.contains, true); 299 _filter(this, elements.contains, true);
300 } 300 }
301 301
302 void removeWhere(bool test(E element)) { 302 void removeWhere(bool test(E element)) {
303 _filter(this, test, false); 303 _filter(this, test, false);
304 } 304 }
305 305
(...skipping 14 matching lines...) Expand all
320 if (length != source.length) { 320 if (length != source.length) {
321 throw new ConcurrentModificationError(source); 321 throw new ConcurrentModificationError(source);
322 } 322 }
323 } 323 }
324 if (retained.length != source.length) { 324 if (retained.length != source.length) {
325 source.setRange(0, retained.length, retained); 325 source.setRange(0, retained.length, retained);
326 source.length = retained.length; 326 source.length = retained.length;
327 } 327 }
328 } 328 }
329 329
330 void clear() { this.length = 0; }
331
330 // List interface. 332 // List interface.
331 333
334 E removeLast() {
335 if (length == 0) {
336 throw new StateError("No elements");
337 }
338 E result = this[length - 1];
339 length--;
340 return result;
341 }
342
332 void sort([Comparator<E> compare]) { 343 void sort([Comparator<E> compare]) {
333 Sort.sort(this, compare); 344 Sort.sort(this, compare);
334 } 345 }
335 346
336 Map<int, E> asMap() { 347 Map<int, E> asMap() {
337 return new ListMapView(this); 348 return new ListMapView(this);
338 } 349 }
339 350
340 List<E> sublist(int start, [int end]) { 351 List<E> sublist(int start, [int end]) {
341 if (end == null) end = length; 352 if (end == null) end = length;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 * the search at index [startIndex] to 0. 444 * the search at index [startIndex] to 0.
434 * Returns -1 if [element] is not found. 445 * Returns -1 if [element] is not found.
435 */ 446 */
436 int lastIndexOf(E element, [int startIndex]) { 447 int lastIndexOf(E element, [int startIndex]) {
437 if (startIndex == null) { 448 if (startIndex == null) {
438 startIndex = this.length - 1; 449 startIndex = this.length - 1;
439 } else { 450 } else {
440 if (startIndex < 0) { 451 if (startIndex < 0) {
441 return -1; 452 return -1;
442 } 453 }
443 if (startIndex >= a.length) { 454 if (startIndex >= this.length) {
444 startIndex = a.length - 1; 455 startIndex = this.length - 1;
445 } 456 }
446 } 457 }
447 for (int i = startIndex; i >= 0; i--) { 458 for (int i = startIndex; i >= 0; i--) {
448 if (this[i] == element) { 459 if (this[i] == element) {
449 return i; 460 return i;
450 } 461 }
451 } 462 }
452 return -1; 463 return -1;
453 } 464 }
454 465
455 Iterable<E> get reversed => new ReversedListIterable(this); 466 Iterable<E> get reversed => new ReversedListIterable(this);
456 } 467 }
OLDNEW
« no previous file with comments | « sdk/lib/collection/hash_set.dart ('k') | sdk/lib/collection/splay_tree.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698