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

Unified Diff: runtime/lib/growable_array.dart

Issue 11169004: 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
Index: runtime/lib/growable_array.dart
diff --git a/runtime/lib/growable_array.dart b/runtime/lib/growable_array.dart
index 58ec00cb106452ad3f0b3dab97503f9d8170925f..e93a9fe4e5afb5d78ce7c263defe3cdf7ffe26f7 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.
- */
+ // Collection interface.
+
+ bool contains(T element) => Collections.contains(this, element);
void forEach(f(T element)) {
// TODO(srdjan): Use Collections.forEach(this, f);
@@ -216,28 +216,6 @@ class _GrowableObjectArray<T> implements List<T> {
}
Iterator<T> iterator() {
- 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 {
+ return new SequenceIterator<T>(this);
}
-
- bool hasNext() {
- return _array.length > _pos;
- }
-
- T next() {
- if (!hasNext()) {
- throw const NoMoreElementsException();
- }
- return _array[_pos++];
- }
-
- final _GrowableObjectArray<T> _array;
- int _pos;
}

Powered by Google App Engine
This is Rietveld 408576698