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

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

Issue 11416240: Address Ivan's comments. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Fix typos Created 8 years 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/byte_array.dart ('k') | runtime/vm/intrinsifier.h » ('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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 void _grow(int new_length) { 165 void _grow(int new_length) {
166 var new_data = new _ObjectArray<T>(new_length); 166 var new_data = new _ObjectArray<T>(new_length);
167 for (int i = 0; i < length; i++) { 167 for (int i = 0; i < length; i++) {
168 new_data[i] = this[i]; 168 new_data[i] = this[i];
169 } 169 }
170 _setData(new_data); 170 _setData(new_data);
171 } 171 }
172 172
173 // Collection interface. 173 // Collection interface.
174 174
175 bool contains(T element) => Collections.contains(this, element); 175 bool contains(T element) {
176 return Collections.contains(this, element);
177 }
176 178
177 void forEach(f(T element)) { 179 void forEach(f(T element)) {
178 // TODO(srdjan): Use Collections.forEach(this, f); 180 // TODO(srdjan): Use Collections.forEach(this, f);
179 // Accessing the list directly improves DeltaBlue performance by 25%. 181 // Accessing the list directly improves DeltaBlue performance by 25%.
180 for (int i = 0; i < length; i++) { 182 for (int i = 0; i < length; i++) {
181 f(this[i]); 183 f(this[i]);
182 } 184 }
183 } 185 }
184 186
185 Iterable mappedBy(f(T element)) => new MappedIterable<T, dynamic>(this, f); 187 Iterable mappedBy(f(T element)) {
188 return new MappedIterable<T, dynamic>(this, f);
189 }
186 190
187 reduce(initialValue, combine(previousValue, T element)) { 191 reduce(initialValue, combine(previousValue, T element)) {
188 return Collections.reduce(this, initialValue, combine); 192 return Collections.reduce(this, initialValue, combine);
189 } 193 }
190 194
191 Iterable<T> where(bool f(T element)) => new WhereIterable<T>(this, f); 195 Iterable<T> where(bool f(T element)) {
196 return new WhereIterable<T>(this, f);
197 }
192 198
193 bool every(bool f(T element)) { 199 bool every(bool f(T element)) {
194 return Collections.every(this, f); 200 return Collections.every(this, f);
195 } 201 }
196 202
197 bool any(bool f(T element)) { 203 bool any(bool f(T element)) {
198 return Collections.any(this, f); 204 return Collections.any(this, f);
199 } 205 }
200 206
201 bool get isEmpty { 207 bool get isEmpty {
202 return this.length == 0; 208 return this.length == 0;
203 } 209 }
204 210
205 void clear() { 211 void clear() {
206 this.length = 0; 212 this.length = 0;
207 } 213 }
208 214
209 void sort([Comparator<T> compare = Comparable.compare]) { 215 void sort([Comparator<T> compare = Comparable.compare]) {
210 _Sort.sort(this, compare); 216 _Sort.sort(this, compare);
211 } 217 }
212 218
213 String toString() { 219 String toString() {
214 return Collections.collectionToString(this); 220 return Collections.collectionToString(this);
215 } 221 }
216 222
217 Iterator<T> get iterator => new SequenceIterator<T>(this); 223 Iterator<T> get iterator {
224 return new SequenceIterator<T>(this);
225 }
218 226
219 List<T> toList() { 227 List<T> toList() {
220 return new List<T>.from(this); 228 return new List<T>.from(this);
221 } 229 }
222 230
223 Set<T> toSet() { 231 Set<T> toSet() {
224 return new Set<T>.from(this); 232 return new Set<T>.from(this);
225 } 233 }
226 } 234 }
OLDNEW
« no previous file with comments | « runtime/lib/byte_array.dart ('k') | runtime/vm/intrinsifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698