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

Unified Diff: tools/dom/src/WrappedList.dart

Issue 13934019: Revert "With the collections deriving from ListBase, we no longer need to implement a number of boi… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « tests/html/node_test.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/WrappedList.dart
diff --git a/tools/dom/src/WrappedList.dart b/tools/dom/src/WrappedList.dart
index 3baff3ee28b81d149e27f699eee63fef5e4e1fdf..7a4ec30606cf16db9898494cef2ab3910f052e26 100644
--- a/tools/dom/src/WrappedList.dart
+++ b/tools/dom/src/WrappedList.dart
@@ -8,7 +8,7 @@ part of dart.dom.html;
* A list which just wraps another list, for either intercepting list calls or
* retyping the list (for example, from List<A> to List<B> where B extends A).
*/
-class _WrappedList<E> extends ListBase<E> {
+class _WrappedList<E> implements List<E> {
final List _list;
_WrappedList(this._list);
@@ -17,14 +17,73 @@ class _WrappedList<E> extends ListBase<E> {
Iterator<E> get iterator => new _WrappedIterator(_list.iterator);
+ Iterable map(f(E element)) => _list.map(f);
+
+ Iterable<E> where(bool f(E element)) => _list.where(f);
+
+ Iterable expand(Iterable f(E element)) => _list.expand(f);
+
+ bool contains(E element) => _list.contains(element);
+
+ void forEach(void f(E element)) { _list.forEach(f); }
+
+ E reduce(E combine(E value, E element)) =>
+ _list.reduce(combine);
+
+ dynamic fold(initialValue, combine(previousValue, E element)) =>
+ _list.fold(initialValue, combine);
+
+ bool every(bool f(E element)) => _list.every(f);
+
+ String join([String separator = ""]) => _list.join(separator);
+
+ bool any(bool f(E element)) => _list.any(f);
+
+ List<E> toList({ bool growable: true }) =>
+ new List.from(_list, growable: growable);
+
+ Set<E> toSet() => _list.toSet();
+
int get length => _list.length;
+ bool get isEmpty => _list.isEmpty;
+
+ Iterable<E> take(int n) => _list.take(n);
+
+ Iterable<E> takeWhile(bool test(E value)) => _list.takeWhile(test);
+
+ Iterable<E> skip(int n) => _list.skip(n);
+
+ Iterable<E> skipWhile(bool test(E value)) => _list.skipWhile(test);
+
+ E get first => _list.first;
+
+ E get last => _list.last;
+
+ E get single => _list.single;
+
+ E firstWhere(bool test(E value), { E orElse() }) =>
+ _list.firstWhere(test, orElse: orElse);
+
+ E lastWhere(bool test(E value), {E orElse()}) =>
+ _list.lastWhere(test, orElse: orElse);
+
+ E singleWhere(bool test(E value)) => _list.singleWhere(test);
+
+ E elementAt(int index) => _list.elementAt(index);
+
// Collection APIs
void add(E element) { _list.add(element); }
+ void addAll(Iterable<E> elements) { _list.addAll(elements); }
+
void remove(Object element) { _list.remove(element); }
+ void removeWhere(bool test(E element)) { _list.removeWhere(test); }
+
+ void retainWhere(bool test(E element)) { _list.retainWhere(test); }
+
void clear() { _list.clear(); }
// List APIs
@@ -35,6 +94,8 @@ class _WrappedList<E> extends ListBase<E> {
void set length(int newLength) { _list.length = newLength; }
+ Iterable<E> get reversed => _list.reversed;
+
void sort([int compare(E a, E b)]) { _list.sort(compare); }
int indexOf(E element, [int start = 0]) => _list.indexOf(element, start);
@@ -43,8 +104,20 @@ class _WrappedList<E> extends ListBase<E> {
void insert(int index, E element) => _list.insert(index, element);
+ void insertAll(int index, Iterable<E> iterable) =>
+ _list.insertAll(index, iterable);
+
+ void setAll(int index, Iterable<E> iterable) =>
+ _list.setAll(index, iterable);
+
E removeAt(int index) => _list.removeAt(index);
+ E removeLast() => _list.removeLast();
+
+ List<E> sublist(int start, [int end]) => _list.sublist(start, end);
+
+ Iterable<E> getRange(int start, int end) => _list.getRange(start, end);
+
void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
_list.setRange(start, end, iterable, skipCount);
}
@@ -58,6 +131,15 @@ class _WrappedList<E> extends ListBase<E> {
void fillRange(int start, int end, [E fillValue]) {
_list.fillRange(start, end, fillValue);
}
+
+ Map<int, E> asMap() => _list.asMap();
+
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
}
/**
« no previous file with comments | « tests/html/node_test.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698