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

Side by Side Diff: test/dart_codegen/expect/collection/linked_list.dart

Issue 1148283010: Remove dart backend (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 part of dart.collection;
2 class LinkedList<E extends LinkedListEntry<E>> extends IterableBase<E> implemen ts _LinkedListLink {int _modificationCount = 0;
3 int _length = 0;
4 _LinkedListLink _next;
5 _LinkedListLink _previous;
6 LinkedList() {
7 _next = _previous = this;
8 }
9 void addFirst(E entry) {
10 _insertAfter(this, entry);
11 }
12 void add(E entry) {
13 _insertAfter(_previous, entry);
14 }
15 void addAll(Iterable<E> entries) {
16 entries.forEach((entry) => _insertAfter(_previous, DEVC$RT.cast(entry, dynamic , E, "CompositeCast", """line 65, column 56 of dart:collection/linked_list.dart: """, entry is E, false)));
17 }
18 bool remove(E entry) {
19 if (entry._list != this) return false;
20 _unlink(entry);
21 return true;
22 }
23 Iterator<E> get iterator => new _LinkedListIterator<E>(this);
24 int get length => _length;
25 void clear() {
26 _modificationCount++;
27 _LinkedListLink next = _next;
28 while (!identical(next, this)) {
29 E entry = DEVC$RT.cast(next, _LinkedListLink, E, "CompositeCast", """line 93 , column 17 of dart:collection/linked_list.dart: """, next is E, false);
30 next = entry._next;
31 entry._next = entry._previous = entry._list = null;
32 }
33 _next = _previous = this;
34 _length = 0;
35 }
36 E get first {
37 if (identical(_next, this)) {
38 throw new StateError('No such element');
39 }
40 return DEVC$RT.cast(_next, _LinkedListLink, E, "CompositeCast", """line 105, column 12 of dart:collection/linked_list.dart: """, _next is E, false);
41 }
42 E get last {
43 if (identical(_previous, this)) {
44 throw new StateError('No such element');
45 }
46 return DEVC$RT.cast(_previous, _LinkedListLink, E, "CompositeCast", """line 1 12, column 12 of dart:collection/linked_list.dart: """, _previous is E, false);
47 }
48 E get single {
49 if (identical(_previous, this)) {
50 throw new StateError('No such element');
51 }
52 if (!identical(_previous, _next)) {
53 throw new StateError('Too many elements');
54 }
55 return DEVC$RT.cast(_next, _LinkedListLink, E, "CompositeCast", """line 122, column 12 of dart:collection/linked_list.dart: """, _next is E, false);
56 }
57 void forEach(void action(E entry)) {
58 int modificationCount = _modificationCount;
59 _LinkedListLink current = _next;
60 while (!identical(current, this)) {
61 action(DEVC$RT.cast(current, _LinkedListLink, E, "CompositeCast", """line 13 4, column 14 of dart:collection/linked_list.dart: """, current is E, false));
62 if (modificationCount != _modificationCount) {
63 throw new ConcurrentModificationError(this);
64 }
65 current = current._next;
66 }
67 }
68 bool get isEmpty => _length == 0;
69 void _insertAfter(_LinkedListLink entry, E newEntry) {
70 if (newEntry.list != null) {
71 throw new StateError('LinkedListEntry is already in a LinkedList');
72 }
73 _modificationCount++;
74 newEntry._list = this;
75 var predecessor = entry;
76 var successor = entry._next;
77 successor._previous = newEntry;
78 newEntry._previous = predecessor;
79 newEntry._next = successor;
80 predecessor._next = newEntry;
81 _length++;
82 }
83 void _unlink(LinkedListEntry<E> entry) {
84 _modificationCount++;
85 entry._next._previous = entry._previous;
86 entry._previous._next = entry._next;
87 _length--;
88 entry._list = entry._next = entry._previous = null;
89 }
90 }
91 class _LinkedListIterator<E extends LinkedListEntry<E>> implements Iterator<E> {final LinkedList<E> _list;
92 final int _modificationCount;
93 E _current;
94 _LinkedListLink _next;
95 _LinkedListIterator(LinkedList<E> list) : _list = list, _modificationCount = li st._modificationCount, _next = list._next;
96 E get current => _current;
97 bool moveNext() {
98 if (identical(_next, _list)) {
99 _current = null;
100 return false;
101 }
102 if (_modificationCount != _list._modificationCount) {
103 throw new ConcurrentModificationError(this);
104 }
105 _current = DEVC$RT.cast(_next, _LinkedListLink, E, "CompositeCast", """line 192 , column 16 of dart:collection/linked_list.dart: """, _next is E, false);
106 _next = _next._next;
107 return true;
108 }
109 }
110 class _LinkedListLink {_LinkedListLink _next;
111 _LinkedListLink _previous;
112 }
113 abstract class LinkedListEntry<E extends LinkedListEntry<E>> implements _Linked ListLink {LinkedList<E> _list;
114 _LinkedListLink _next;
115 _LinkedListLink _previous;
116 LinkedList<E> get list => _list;
117 void unlink() {
118 _list._unlink(this);
119 }
120 E get next {
121 if (identical(_next, _list)) return null;
122 E result = DEVC$RT.cast(_next, _LinkedListLink, E, "CompositeCast", """line 249 , column 16 of dart:collection/linked_list.dart: """, _next is E, false);
123 return result;
124 }
125 E get previous {
126 if (identical(_previous, _list)) return null;
127 return DEVC$RT.cast(_previous, _LinkedListLink, E, "CastUser", """line 261, col umn 12 of dart:collection/linked_list.dart: """, _previous is E, false);
128 }
129 void insertAfter(E entry) {
130 _list._insertAfter(this, entry);
131 }
132 void insertBefore(E entry) {
133 _list._insertAfter(_previous, entry);
134 }
135 }
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/collection/linked_hash_set.dart ('k') | test/dart_codegen/expect/collection/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698