Fix an old TODO.

R=floitsch@google.com

Review URL: https://codereview.chromium.org//107333003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31253 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
ngeoffray@google.com 2013-12-19 10:40:53 +00:00
parent d9f262fe2b
commit 2015e5f204
7 changed files with 26 additions and 27 deletions

View file

@ -78,7 +78,7 @@ class _List<E> implements List<E> {
_copyFromObjectArray(iterable, skipCount, start, length);
} else {
if (iterable is List) {
Arrays.copy(iterable, skipCount, this, start, length);
Lists.copy(iterable, skipCount, this, start, length);
} else {
Iterator it = iterable.iterator;
while (skipCount > 0) {
@ -108,13 +108,13 @@ class _List<E> implements List<E> {
}
List<E> sublist(int start, [int end]) {
Arrays.indicesCheck(this, start, end);
Lists.indicesCheck(this, start, end);
if (end == null) end = this.length;
int length = end - start;
if (start == end) return [];
List list = new _GrowableList<E>.withCapacity(length);
list.length = length;
Arrays.copy(this, start, list, 0, length);
Lists.copy(this, start, list, 0, length);
return list;
}
@ -209,12 +209,12 @@ class _List<E> implements List<E> {
}
int indexOf(Object element, [int start = 0]) {
return Arrays.indexOf(this, element, start, this.length);
return Lists.indexOf(this, element, start, this.length);
}
int lastIndexOf(Object element, [int start = null]) {
if (start == null) start = length - 1;
return Arrays.lastIndexOf(this, element, start);
return Lists.lastIndexOf(this, element, start);
}
Iterator<E> get iterator {
@ -361,13 +361,13 @@ class _ImmutableList<E> implements List<E> {
}
List<E> sublist(int start, [int end]) {
Arrays.indicesCheck(this, start, end);
Lists.indicesCheck(this, start, end);
if (end == null) end = this.length;
int length = end - start;
if (start == end) return [];
List list = new List<E>();
list.length = length;
Arrays.copy(this, start, list, 0, length);
Lists.copy(this, start, list, 0, length);
return list;
}
@ -472,12 +472,12 @@ class _ImmutableList<E> implements List<E> {
}
int indexOf(Object element, [int start = 0]) {
return Arrays.indexOf(this, element, start, this.length);
return Lists.indexOf(this, element, start, this.length);
}
int lastIndexOf(Object element, [int start = null]) {
if (start == null) start = length - 1;
return Arrays.lastIndexOf(this, element, start);
return Lists.lastIndexOf(this, element, start);
}
Iterator<E> get iterator {

View file

@ -19,7 +19,7 @@ class _GrowableList<T> implements List<T> {
// (with a length that has been increased, but without a new element).
if (index is! int) throw new ArgumentError(index);
this.length++;
Arrays.copy(this,
Lists.copy(this,
index,
this,
index + 1,
@ -31,7 +31,7 @@ class _GrowableList<T> implements List<T> {
if (index is! int) throw new ArgumentError(index);
T result = this[index];
int newLength = this.length - 1;
Arrays.copy(this,
Lists.copy(this,
index + 1,
this,
index,
@ -95,8 +95,8 @@ class _GrowableList<T> implements List<T> {
}
void removeRange(int start, int end) {
Arrays.indicesCheck(this, start, end);
Arrays.copy(this,
Lists.indicesCheck(this, start, end);
Lists.copy(this,
end,
this,
start,
@ -113,13 +113,13 @@ class _GrowableList<T> implements List<T> {
}
List<T> sublist(int start, [int end]) {
Arrays.indicesCheck(this, start, end);
Lists.indicesCheck(this, start, end);
if (end == null) end = this.length;
int length = end - start;
if (start == end) return <T>[];
List list = new _GrowableList<T>.withCapacity(length);
list.length = length;
Arrays.copy(this, start, list, 0, length);
Lists.copy(this, start, list, 0, length);
return list;
}

View file

@ -10,9 +10,9 @@ import 'dart:core' hide Symbol;
import 'dart:core' as core;
import 'dart:math' show Random;
part 'arrays.dart';
part 'iterable.dart';
part 'list.dart';
part 'lists.dart';
part 'print.dart';
part 'sort.dart';
part 'symbol.dart';

View file

@ -7,9 +7,9 @@
'sources': [
'collection_dev.dart',
# The above file needs to be first as it lists the parts below.
'arrays.dart',
'iterable.dart',
'list.dart',
'lists.dart',
'print.dart',
'sort.dart',
'symbol.dart',

View file

@ -1016,12 +1016,12 @@ class IterableMixinWorkaround {
}
static int indexOfList(List list, var element, int start) {
return Arrays.indexOf(list, element, start, list.length);
return Lists.indexOf(list, element, start, list.length);
}
static int lastIndexOfList(List list, var element, int start) {
if (start == null) start = list.length - 1;
return Arrays.lastIndexOf(list, element, start);
return Lists.lastIndexOf(list, element, start);
}
static void _rangeCheck(List list, int start, int end) {
@ -1060,7 +1060,7 @@ class IterableMixinWorkaround {
if (otherStart + length > otherList.length) {
throw new StateError("Not enough elements");
}
Arrays.copy(otherList, otherStart, list, start, length);
Lists.copy(otherList, otherStart, list, start, length);
}
static void replaceRangeList(List list, int start, int end,

View file

@ -4,8 +4,7 @@
part of dart._collection.dev;
// TODO(ngeoffray): Rename to Lists.
class Arrays {
class Lists {
static void copy(List src, int srcStart,
List dst, int dstStart, int count) {
if (srcStart < dstStart) {

View file

@ -269,11 +269,11 @@ class JSArray<E> extends Interceptor implements List<E>, JSIndexable {
if (end < start || end > receiverLength) {
throw new RangeError.range(end, start, receiverLength);
}
Arrays.copy(this,
end,
this,
start,
receiverLength - end);
Lists.copy(this,
end,
this,
start,
receiverLength - end);
this.length = receiverLength - (end - start);
}