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

Unified Diff: tools/dom/templates/immutable_list_mixin.darttemplate

Issue 14036014: Updating DOM code to use list mixins (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « tools/dom/templates/html/impl/impl_TouchList.darttemplate ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/templates/immutable_list_mixin.darttemplate
diff --git a/tools/dom/templates/immutable_list_mixin.darttemplate b/tools/dom/templates/immutable_list_mixin.darttemplate
index a984eabf8383a0f3f06b309979e96268f9cfa859..e9bffe58e4524018b0aefc00e13bd149a0d22d17 100644
--- a/tools/dom/templates/immutable_list_mixin.darttemplate
+++ b/tools/dom/templates/immutable_list_mixin.darttemplate
@@ -1,208 +1,15 @@
// -- start List<$E> mixins.
// $E is the element type.
- // From Iterable<$E>:
-
- Iterator<$E> get iterator {
- // Note: NodeLists are not fixed size. And most probably length shouldn't
- // be cached in both iterator _and_ forEach method. For now caching it
- // for consistency.
- return new FixedSizeListIterator<$E>(this);
- }
-
$if DEFINE_LENGTH_AS_NUM_ITEMS
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
$endif
- $E reduce($E combine($E value, $E element)) {
- return IterableMixinWorkaround.reduce(this, combine);
- }
-
- dynamic fold(dynamic initialValue,
- dynamic combine(dynamic previousValue, $E element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
- }
-
-$if DEFINE_CONTAINS
- bool contains($E element) => IterableMixinWorkaround.contains(this, element);
-$else
- // contains() defined by IDL.
-$endif
-
- void forEach(void f($E element)) => IterableMixinWorkaround.forEach(this, f);
-
- String join([String separator = ""]) =>
- IterableMixinWorkaround.joinList(this, separator);
-
- Iterable map(f($E element)) =>
- IterableMixinWorkaround.mapList(this, f);
-
- Iterable<$E> where(bool f($E element)) =>
- IterableMixinWorkaround.where(this, f);
-
- Iterable expand(Iterable f($E element)) =>
- IterableMixinWorkaround.expand(this, f);
-
- bool every(bool f($E element)) => IterableMixinWorkaround.every(this, f);
-
- bool any(bool f($E element)) => IterableMixinWorkaround.any(this, f);
-
- List<$E> toList({ bool growable: true }) =>
- new List<$E>.from(this, growable: growable);
-
- Set<$E> toSet() => new Set<$E>.from(this);
-
- bool get isEmpty => this.length == 0;
-
- Iterable<$E> take(int n) => IterableMixinWorkaround.takeList(this, n);
-
- Iterable<$E> takeWhile(bool test($E value)) {
- return IterableMixinWorkaround.takeWhile(this, test);
- }
- Iterable<$E> skip(int n) => IterableMixinWorkaround.skipList(this, n);
-
- Iterable<$E> skipWhile(bool test($E value)) {
- return IterableMixinWorkaround.skipWhile(this, test);
- }
-
- $E firstWhere(bool test($E value), { $E orElse() }) {
- return IterableMixinWorkaround.firstWhere(this, test, orElse);
- }
-
- $E lastWhere(bool test($E value), {$E orElse()}) {
- return IterableMixinWorkaround.lastWhereList(this, test, orElse);
- }
-
- $E singleWhere(bool test($E value)) {
- return IterableMixinWorkaround.singleWhere(this, test);
- }
-
- $E elementAt(int index) {
- return this[index];
- }
-
- // From Collection<$E>:
-
- void add($E value) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void addAll(Iterable<$E> iterable) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- // From List<$E>:
$if DEFINE_LENGTH_SETTER
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
}
$endif
-$if DEFINE_CLEAR
- void clear() {
- throw new UnsupportedError("Cannot clear immutable List.");
- }
-$else
- // clear() defined by IDL.
-$endif
-
- Iterable<$E> get reversed {
- return IterableMixinWorkaround.reversedList(this);
- }
-
- void sort([int compare($E a, $E b)]) {
- throw new UnsupportedError("Cannot sort immutable List.");
- }
-
- int indexOf($E element, [int start = 0]) =>
- Lists.indexOf(this, element, start, this.length);
-
- int lastIndexOf($E element, [int start]) {
- if (start == null) start = length - 1;
- return Lists.lastIndexOf(this, element, start);
- }
-
- $E get first {
- if (this.length > 0) return this[0];
- throw new StateError("No elements");
- }
-
- $E get last {
- if (this.length > 0) return this[this.length - 1];
- throw new StateError("No elements");
- }
-
- $E get single {
- if (length == 1) return this[0];
- if (length == 0) throw new StateError("No elements");
- throw new StateError("More than one element");
- }
-
- void insert(int index, $E element) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void insertAll(int index, Iterable<$E> iterable) {
- throw new UnsupportedError("Cannot add to immutable List.");
- }
-
- void setAll(int index, Iterable<$E> iterable) {
- throw new UnsupportedError("Cannot modify an immutable List.");
- }
-
- $E removeAt(int pos) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- $E removeLast() {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- bool remove(Object object) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void removeWhere(bool test($E element)) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainWhere(bool test($E element)) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void setRange(int start, int end, Iterable<$E> iterable, [int skipCount=0]) {
- throw new UnsupportedError("Cannot setRange on immutable List.");
- }
-
- void removeRange(int start, int end) {
- throw new UnsupportedError("Cannot removeRange on immutable List.");
- }
-
- void replaceRange(int start, int end, Iterable<$E> iterable) {
- throw new UnsupportedError("Cannot modify an immutable List.");
- }
-
- void fillRange(int start, int end, [$E fillValue]) {
- throw new UnsupportedError("Cannot modify an immutable List.");
- }
-
- Iterable<$E> getRange(int start, int end) =>
- IterableMixinWorkaround.getRangeList(this, start, end);
-
- List<$E> sublist(int start, [int end]) {
- if (end == null) end = length;
- return Lists.getRange(this, start, end, <$E>[]);
- }
-
- Map<int, $E> asMap() =>
- IterableMixinWorkaround.asMapList(this);
-
- String toString() {
- StringBuffer buffer = new StringBuffer('[');
- buffer.writeAll(this, ', ');
- buffer.write(']');
- return buffer.toString();
- }
-
// -- end List<$E> mixins.
« no previous file with comments | « tools/dom/templates/html/impl/impl_TouchList.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698