Index: runtime/lib/growable_array.dart |
diff --git a/runtime/lib/growable_array.dart b/runtime/lib/growable_array.dart |
index ad4765b65ce1f5a8722d84a250fb6ccdd58e47b7..e332dd1aac8a6489cba621ecf7c86850832f32c5 100644 |
--- a/runtime/lib/growable_array.dart |
+++ b/runtime/lib/growable_array.dart |
@@ -166,9 +166,9 @@ class _GrowableObjectArray<T> implements List<T> { |
_setData(new_data); |
} |
- // Collection interface. |
- |
- bool contains(T element) => Collections.contains(this, element); |
+ /** |
+ * Collection interface. |
+ */ |
void forEach(f(T element)) { |
// TODO(srdjan): Use Collections.forEach(this, f); |
@@ -216,6 +216,28 @@ class _GrowableObjectArray<T> implements List<T> { |
} |
Iterator<T> iterator() { |
- return new SequenceIterator<T>(this); |
+ return new VariableSizeArrayIterator<T>(this); |
+ } |
+} |
+ |
+ |
+// Iterator for arrays with variable size. |
+class VariableSizeArrayIterator<T> implements Iterator<T> { |
+ VariableSizeArrayIterator(_GrowableObjectArray<T> array) |
+ : _array = array, _pos = 0 { |
} |
+ |
+ bool hasNext() { |
+ return _array.length > _pos; |
+ } |
+ |
+ T next() { |
+ if (!hasNext()) { |
+ throw const NoMoreElementsException(); |
+ } |
+ return _array[_pos++]; |
+ } |
+ |
+ final _GrowableObjectArray<T> _array; |
+ int _pos; |
} |