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

Side by Side Diff: runtime/lib/growable_array.dart

Issue 14173003: Remove Collection, Collections and clean up List/Set/Queue implementations of retain/remove. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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 class _GrowableObjectArray<T> implements List<T> { 5 class _GrowableObjectArray<T> implements List<T> {
6 factory _GrowableObjectArray._uninstantiable() { 6 factory _GrowableObjectArray._uninstantiable() {
7 throw new UnsupportedError( 7 throw new UnsupportedError(
8 "GrowableObjectArray can only be allocated by the VM"); 8 "GrowableObjectArray can only be allocated by the VM");
9 } 9 }
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 void remove(Object element) { 46 void remove(Object element) {
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 removeAt(i); 49 removeAt(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(T element)) { 55 void removeWhere(bool test(T element)) {
64 IterableMixinWorkaround.removeWhereList(this, test); 56 IterableMixinWorkaround.removeWhereList(this, test);
65 } 57 }
66 58
67 void retainWhere(bool test(T element)) { 59 void retainWhere(bool test(T element)) {
68 IterableMixinWorkaround.removeWhereList(this, 60 IterableMixinWorkaround.removeWhereList(this,
69 (T element) => !test(element)); 61 (T element) => !test(element));
70 } 62 }
71 63
72 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { 64 void setRange(int start, int length, List<T> from, [int startFrom = 0]) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 var result = new _GrowableObjectArray<T>.withData(data); 118 var result = new _GrowableObjectArray<T>.withData(data);
127 result._setLength(length); 119 result._setLength(length);
128 return result; 120 return result;
129 } 121 }
130 122
131 factory _GrowableObjectArray.withCapacity(int capacity) { 123 factory _GrowableObjectArray.withCapacity(int capacity) {
132 var data = new _ObjectArray((capacity == 0)? 4 : capacity); 124 var data = new _ObjectArray((capacity == 0)? 4 : capacity);
133 return new _GrowableObjectArray<T>.withData(data); 125 return new _GrowableObjectArray<T>.withData(data);
134 } 126 }
135 127
136 factory _GrowableObjectArray.from(Collection<T> other) { 128 factory _GrowableObjectArray.from(Iterable<T> other) {
137 List<T> result = new _GrowableObjectArray<T>(); 129 List<T> result = new _GrowableObjectArray<T>();
138 result.addAll(other); 130 result.addAll(other);
139 return result; 131 return result;
140 } 132 }
141 133
142 factory _GrowableObjectArray.withData(_ObjectArray data) 134 factory _GrowableObjectArray.withData(_ObjectArray data)
143 native "GrowableObjectArray_allocate"; 135 native "GrowableObjectArray_allocate";
144 136
145 int get length native "GrowableObjectArray_getLength"; 137 int get length native "GrowableObjectArray_getLength";
146 138
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 this.length = 0; 316 this.length = 0;
325 } 317 }
326 318
327 Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this); 319 Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this);
328 320
329 void sort([int compare(T a, T b)]) { 321 void sort([int compare(T a, T b)]) {
330 IterableMixinWorkaround.sortList(this, compare); 322 IterableMixinWorkaround.sortList(this, compare);
331 } 323 }
332 324
333 String toString() { 325 String toString() {
334 return Collections.collectionToString(this); 326 return ToString.iterableToString(this);
335 } 327 }
336 328
337 Iterator<T> get iterator { 329 Iterator<T> get iterator {
338 return new ListIterator<T>(this); 330 return new ListIterator<T>(this);
339 } 331 }
340 332
341 List<T> toList({ bool growable: true }) { 333 List<T> toList({ bool growable: true }) {
342 return new List<T>.from(this, growable: growable); 334 return new List<T>.from(this, growable: growable);
343 } 335 }
344 336
345 Set<T> toSet() { 337 Set<T> toSet() {
346 return new Set<T>.from(this); 338 return new Set<T>.from(this);
347 } 339 }
348 340
349 Map<int, T> asMap() { 341 Map<int, T> asMap() {
350 return IterableMixinWorkaround.asMapList(this); 342 return IterableMixinWorkaround.asMapList(this);
351 } 343 }
352 } 344 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698