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

Unified Diff: runtime/lib/growable_array.dart

Issue 11186045: Revert "Add "contains" method to Collection." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/byte_array.dart ('k') | tests/corelib/collection_to_string_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « runtime/lib/byte_array.dart ('k') | tests/corelib/collection_to_string_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698