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

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

Issue 13872007: Refactor removeRange. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files and rebuild dom (unrelated CL). 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 Iterable<T> getRange(int start, int end) { 64 Iterable<T> getRange(int start, int end) {
65 return IterableMixinWorkaround.getRangeList(this, start, end); 65 return IterableMixinWorkaround.getRangeList(this, start, end);
66 } 66 }
67 67
68 void setRange(int start, int end, Iterable<T> iterable, [int skipCount = 0]) { 68 void setRange(int start, int end, Iterable<T> iterable, [int skipCount = 0]) {
69 IterableMixinWorkaround.setRangeList(this, start, end, iterable, skipCount); 69 IterableMixinWorkaround.setRangeList(this, start, end, iterable, skipCount);
70 } 70 }
71 71
72 void removeRange(int start, int length) { 72 void removeRange(int start, int end) {
73 if (length == 0) { 73 Arrays.indicesCheck(this, start, end);
74 return;
75 }
76 Arrays.rangeCheck(this, start, length);
77 Arrays.copy(this, 74 Arrays.copy(this,
78 start + length, 75 end,
79 this, 76 this,
80 start, 77 start,
81 this.length - length - start); 78 this.length - end);
82 this.length = this.length - length; 79 this.length = this.length - (end - start);
83 } 80 }
84 81
85 void insertRange(int start, int length, [T initialValue = null]) { 82 void insertRange(int start, int length, [T initialValue = null]) {
86 if (length == 0) { 83 if (length == 0) {
87 return; 84 return;
88 } 85 }
89 if ((length < 0) || (length is! int)) { 86 if ((length < 0) || (length is! int)) {
90 throw new ArgumentError("invalid length specified $length"); 87 throw new ArgumentError("invalid length specified $length");
91 } 88 }
92 if (start < 0 || start > this.length) { 89 if (start < 0 || start > this.length) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 334 }
338 335
339 Set<T> toSet() { 336 Set<T> toSet() {
340 return new Set<T>.from(this); 337 return new Set<T>.from(this);
341 } 338 }
342 339
343 Map<int, T> asMap() { 340 Map<int, T> asMap() {
344 return IterableMixinWorkaround.asMapList(this); 341 return IterableMixinWorkaround.asMapList(this);
345 } 342 }
346 } 343 }
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