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); _copyFromObjectArray(iterable, skipCount, start, length);
} else { } else {
if (iterable is List) { if (iterable is List) {
Arrays.copy(iterable, skipCount, this, start, length); Lists.copy(iterable, skipCount, this, start, length);
} else { } else {
Iterator it = iterable.iterator; Iterator it = iterable.iterator;
while (skipCount > 0) { while (skipCount > 0) {
@ -108,13 +108,13 @@ class _List<E> implements List<E> {
} }
List<E> sublist(int start, [int end]) { List<E> sublist(int start, [int end]) {
Arrays.indicesCheck(this, start, end); Lists.indicesCheck(this, start, end);
if (end == null) end = this.length; if (end == null) end = this.length;
int length = end - start; int length = end - start;
if (start == end) return []; if (start == end) return [];
List list = new _GrowableList<E>.withCapacity(length); List list = new _GrowableList<E>.withCapacity(length);
list.length = length; list.length = length;
Arrays.copy(this, start, list, 0, length); Lists.copy(this, start, list, 0, length);
return list; return list;
} }
@ -209,12 +209,12 @@ class _List<E> implements List<E> {
} }
int indexOf(Object element, [int start = 0]) { 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]) { int lastIndexOf(Object element, [int start = null]) {
if (start == null) start = length - 1; if (start == null) start = length - 1;
return Arrays.lastIndexOf(this, element, start); return Lists.lastIndexOf(this, element, start);
} }
Iterator<E> get iterator { Iterator<E> get iterator {
@ -361,13 +361,13 @@ class _ImmutableList<E> implements List<E> {
} }
List<E> sublist(int start, [int end]) { List<E> sublist(int start, [int end]) {
Arrays.indicesCheck(this, start, end); Lists.indicesCheck(this, start, end);
if (end == null) end = this.length; if (end == null) end = this.length;
int length = end - start; int length = end - start;
if (start == end) return []; if (start == end) return [];
List list = new List<E>(); List list = new List<E>();
list.length = length; list.length = length;
Arrays.copy(this, start, list, 0, length); Lists.copy(this, start, list, 0, length);
return list; return list;
} }
@ -472,12 +472,12 @@ class _ImmutableList<E> implements List<E> {
} }
int indexOf(Object element, [int start = 0]) { 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]) { int lastIndexOf(Object element, [int start = null]) {
if (start == null) start = length - 1; if (start == null) start = length - 1;
return Arrays.lastIndexOf(this, element, start); return Lists.lastIndexOf(this, element, start);
} }
Iterator<E> get iterator { 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). // (with a length that has been increased, but without a new element).
if (index is! int) throw new ArgumentError(index); if (index is! int) throw new ArgumentError(index);
this.length++; this.length++;
Arrays.copy(this, Lists.copy(this,
index, index,
this, this,
index + 1, index + 1,
@ -31,7 +31,7 @@ class _GrowableList<T> implements List<T> {
if (index is! int) throw new ArgumentError(index); if (index is! int) throw new ArgumentError(index);
T result = this[index]; T result = this[index];
int newLength = this.length - 1; int newLength = this.length - 1;
Arrays.copy(this, Lists.copy(this,
index + 1, index + 1,
this, this,
index, index,
@ -95,8 +95,8 @@ class _GrowableList<T> implements List<T> {
} }
void removeRange(int start, int end) { void removeRange(int start, int end) {
Arrays.indicesCheck(this, start, end); Lists.indicesCheck(this, start, end);
Arrays.copy(this, Lists.copy(this,
end, end,
this, this,
start, start,
@ -113,13 +113,13 @@ class _GrowableList<T> implements List<T> {
} }
List<T> sublist(int start, [int end]) { List<T> sublist(int start, [int end]) {
Arrays.indicesCheck(this, start, end); Lists.indicesCheck(this, start, end);
if (end == null) end = this.length; if (end == null) end = this.length;
int length = end - start; int length = end - start;
if (start == end) return <T>[]; if (start == end) return <T>[];
List list = new _GrowableList<T>.withCapacity(length); List list = new _GrowableList<T>.withCapacity(length);
list.length = length; list.length = length;
Arrays.copy(this, start, list, 0, length); Lists.copy(this, start, list, 0, length);
return list; return list;
} }

View file

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

View file

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

View file

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

View file

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

View file

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