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

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
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/typeddata.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) 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 Iterable<T> getRange(int start, int end) { 64 Iterable<T> getRange(int start, int end) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 var result = new _GrowableObjectArray<T>.withData(data); 120 var result = new _GrowableObjectArray<T>.withData(data);
129 result._setLength(length); 121 result._setLength(length);
130 return result; 122 return result;
131 } 123 }
132 124
133 factory _GrowableObjectArray.withCapacity(int capacity) { 125 factory _GrowableObjectArray.withCapacity(int capacity) {
134 var data = new _ObjectArray((capacity == 0)? 4 : capacity); 126 var data = new _ObjectArray((capacity == 0)? 4 : capacity);
135 return new _GrowableObjectArray<T>.withData(data); 127 return new _GrowableObjectArray<T>.withData(data);
136 } 128 }
137 129
138 factory _GrowableObjectArray.from(Collection<T> other) { 130 factory _GrowableObjectArray.from(Iterable<T> other) {
139 List<T> result = new _GrowableObjectArray<T>(); 131 List<T> result = new _GrowableObjectArray<T>();
140 result.addAll(other); 132 result.addAll(other);
141 return result; 133 return result;
142 } 134 }
143 135
144 factory _GrowableObjectArray.withData(_ObjectArray data) 136 factory _GrowableObjectArray.withData(_ObjectArray data)
145 native "GrowableObjectArray_allocate"; 137 native "GrowableObjectArray_allocate";
146 138
147 int get length native "GrowableObjectArray_getLength"; 139 int get length native "GrowableObjectArray_getLength";
148 140
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 this.length = 0; 318 this.length = 0;
327 } 319 }
328 320
329 Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this); 321 Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this);
330 322
331 void sort([int compare(T a, T b)]) { 323 void sort([int compare(T a, T b)]) {
332 IterableMixinWorkaround.sortList(this, compare); 324 IterableMixinWorkaround.sortList(this, compare);
333 } 325 }
334 326
335 String toString() { 327 String toString() {
336 return Collections.collectionToString(this); 328 return ToString.iterableToString(this);
337 } 329 }
338 330
339 Iterator<T> get iterator { 331 Iterator<T> get iterator {
340 return new ListIterator<T>(this); 332 return new ListIterator<T>(this);
341 } 333 }
342 334
343 List<T> toList({ bool growable: true }) { 335 List<T> toList({ bool growable: true }) {
344 return new List<T>.from(this, growable: growable); 336 return new List<T>.from(this, growable: growable);
345 } 337 }
346 338
347 Set<T> toSet() { 339 Set<T> toSet() {
348 return new Set<T>.from(this); 340 return new Set<T>.from(this);
349 } 341 }
350 342
351 Map<int, T> asMap() { 343 Map<int, T> asMap() {
352 return IterableMixinWorkaround.asMapList(this); 344 return IterableMixinWorkaround.asMapList(this);
353 } 345 }
354 } 346 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/typeddata.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698