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

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: Rebuild dom. 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 Iterable<T> getRange(int start, int end) { 72 Iterable<T> getRange(int start, int end) {
73 return IterableMixinWorkaround.getRangeList(this, start, end); 73 return IterableMixinWorkaround.getRangeList(this, start, end);
74 } 74 }
75 75
76 void setRange(int start, int end, List<T> from, [int startFrom = 0]) { 76 void setRange(int start, int end, List<T> from, [int startFrom = 0]) {
77 IterableMixinWorkaround.setRangeList(this, start, end, from, startFrom); 77 IterableMixinWorkaround.setRangeList(this, start, end, from, startFrom);
78 } 78 }
79 79
80 void removeRange(int start, int length) { 80 void removeRange(int start, int end) {
81 if (length == 0) { 81 Arrays.indicesCheck(this, start, end);
82 return;
83 }
84 Arrays.rangeCheck(this, start, length);
85 Arrays.copy(this, 82 Arrays.copy(this,
86 start + length, 83 end,
87 this, 84 this,
88 start, 85 start,
89 this.length - length - start); 86 this.length - end);
90 this.length = this.length - length; 87 this.length = this.length - (end - start);
91 } 88 }
92 89
93 void insertRange(int start, int length, [T initialValue = null]) { 90 void insertRange(int start, int length, [T initialValue = null]) {
94 if (length == 0) { 91 if (length == 0) {
95 return; 92 return;
96 } 93 }
97 if ((length < 0) || (length is! int)) { 94 if ((length < 0) || (length is! int)) {
98 throw new ArgumentError("invalid length specified $length"); 95 throw new ArgumentError("invalid length specified $length");
99 } 96 }
100 if (start < 0 || start > this.length) { 97 if (start < 0 || start > this.length) {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 346 }
350 347
351 Set<T> toSet() { 348 Set<T> toSet() {
352 return new Set<T>.from(this); 349 return new Set<T>.from(this);
353 } 350 }
354 351
355 Map<int, T> asMap() { 352 Map<int, T> asMap() {
356 return IterableMixinWorkaround.asMapList(this); 353 return IterableMixinWorkaround.asMapList(this);
357 } 354 }
358 } 355 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698