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

Side by Side Diff: sdk/lib/html/templates/immutable_list_mixin.darttemplate

Issue 11316059: Add List.first. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add dart2js interceptor and add test. Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // -- start List<$E> mixins. 1 // -- start List<$E> mixins.
2 // $E is the element type. 2 // $E is the element type.
3 3
4 // From Iterable<$E>: 4 // From Iterable<$E>:
5 5
6 Iterator<$E> iterator() { 6 Iterator<$E> iterator() {
7 // Note: NodeLists are not fixed size. And most probably length shouldn't 7 // Note: NodeLists are not fixed size. And most probably length shouldn't
8 // be cached in both iterator _and_ forEach method. For now caching it 8 // be cached in both iterator _and_ forEach method. For now caching it
9 // for consistency. 9 // for consistency.
10 return new FixedSizeListIterator<$E>(this); 10 return new FixedSizeListIterator<$E>(this);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 int indexOf($E element, [int start = 0]) => 52 int indexOf($E element, [int start = 0]) =>
53 _Lists.indexOf(this, element, start, this.length); 53 _Lists.indexOf(this, element, start, this.length);
54 54
55 int lastIndexOf($E element, [int start]) { 55 int lastIndexOf($E element, [int start]) {
56 if (start == null) start = length - 1; 56 if (start == null) start = length - 1;
57 return _Lists.lastIndexOf(this, element, start); 57 return _Lists.lastIndexOf(this, element, start);
58 } 58 }
59 59
60 $E get first => this[0];
61
60 $E get last => this[length - 1]; 62 $E get last => this[length - 1];
61 63
62 $E removeLast() { 64 $E removeLast() {
63 throw new UnsupportedError("Cannot removeLast on immutable List."); 65 throw new UnsupportedError("Cannot removeLast on immutable List.");
64 } 66 }
65 67
66 void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) { 68 void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) {
67 throw new UnsupportedError("Cannot setRange on immutable List."); 69 throw new UnsupportedError("Cannot setRange on immutable List.");
68 } 70 }
69 71
70 void removeRange(int start, int rangeLength) { 72 void removeRange(int start, int rangeLength) {
71 throw new UnsupportedError("Cannot removeRange on immutable List."); 73 throw new UnsupportedError("Cannot removeRange on immutable List.");
72 } 74 }
73 75
74 void insertRange(int start, int rangeLength, [$E initialValue]) { 76 void insertRange(int start, int rangeLength, [$E initialValue]) {
75 throw new UnsupportedError("Cannot insertRange on immutable List."); 77 throw new UnsupportedError("Cannot insertRange on immutable List.");
76 } 78 }
77 79
78 List<$E> getRange(int start, int rangeLength) => 80 List<$E> getRange(int start, int rangeLength) =>
79 _Lists.getRange(this, start, rangeLength, <$E>[]); 81 _Lists.getRange(this, start, rangeLength, <$E>[]);
80 82
81 // -- end List<$E> mixins. 83 // -- end List<$E> mixins.
OLDNEW
« no previous file with comments | « sdk/lib/html/templates/html/impl/impl_NodeList.darttemplate ('k') | sdk/lib/svg/dart2js/svg_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698