| Index: runtime/lib/list_implementation.dart
|
| ===================================================================
|
| --- runtime/lib/list_implementation.dart (revision 505)
|
| +++ runtime/lib/list_implementation.dart (working copy)
|
| @@ -2,7 +2,7 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -class GrowableObjectArray<T> implements Array<T> {
|
| +class ListImplementation<T> implements Array<T> {
|
| ObjectArray<T> backingArray;
|
|
|
| void copyFrom(List<Object> src, int srcStart, int dstStart, int count) {
|
| @@ -76,10 +76,10 @@
|
| // is not in the array.
|
| static final int ABSENT = -1;
|
|
|
| - GrowableObjectArray()
|
| + ListImplementation()
|
| : _length = 0, backingArray = new ObjectArray<T>(4) {}
|
|
|
| - GrowableObjectArray.withCapacity(int capacity) {
|
| + ListImplementation.withCapacity(int capacity) {
|
| _length = 0;
|
| if (capacity <= 0) {
|
| capacity = 4;
|
| @@ -87,7 +87,7 @@
|
| backingArray = new ObjectArray<T>(capacity);
|
| }
|
|
|
| - GrowableObjectArray._usingArray(Array<T> array) {
|
| + ListImplementation._usingArray(Array<T> array) {
|
| backingArray = array;
|
| _length = array.length;
|
| if (_length == 0) {
|
| @@ -95,8 +95,8 @@
|
| }
|
| }
|
|
|
| - factory GrowableObjectArray.from(Collection<T> other) {
|
| - Array result = new GrowableObjectArray();
|
| + factory ListImplementation.from(Collection<T> other) {
|
| + List result = new List();
|
| result.addAll(other);
|
| return result;
|
| }
|
| @@ -190,7 +190,7 @@
|
| }
|
|
|
| Collection<T> filter(bool f(T element)) {
|
| - return Collections.filter(this, new GrowableObjectArray<T>(), f);
|
| + return Collections.filter(this, new List<T>(), f);
|
| }
|
|
|
| bool every(bool f(T element)) {
|
| @@ -214,29 +214,27 @@
|
| }
|
|
|
| Iterator<T> iterator() {
|
| - return new VariableSizeArrayIterator<T>(this);
|
| + return new ListIterator<T>(this);
|
| }
|
| }
|
|
|
|
|
| -// Iterator for arrays with variable size.
|
| -class VariableSizeArrayIterator<T> implements Iterator<T> {
|
| - VariableSizeArrayIterator(GrowableObjectArray<T> array)
|
| - : _array = array, _pos = 0 {
|
| - }
|
| +// Iterator for lists with variable size.
|
| +class ListIterator<T> implements Iterator<T> {
|
| + ListIterator(List<T> this._list) : _pos = 0;
|
|
|
| bool hasNext() {
|
| - return _array._length > _pos;
|
| + return _list._length > _pos;
|
| }
|
|
|
| T next() {
|
| if (!hasNext()) {
|
| throw const NoMoreElementsException();
|
| }
|
| - return _array[_pos++];
|
| + return _list[_pos++];
|
| }
|
|
|
| - final GrowableObjectArray<T> _array;
|
| + final List<T> _list;
|
| int _pos;
|
| }
|
|
|
|
|