OLD | NEW |
1 part of dart.collection; | 1 part of dart.collection; |
2 class LinkedList<E extends LinkedListEntry<E>> extends IterableBase<E> implemen
ts _LinkedListLink {int _modificationCount = 0; | 2 class LinkedList<E extends LinkedListEntry<E>> extends IterableBase<E> implemen
ts _LinkedListLink {int _modificationCount = 0; |
3 int _length = 0; | 3 int _length = 0; |
4 _LinkedListLink _next; | 4 _LinkedListLink _next; |
5 _LinkedListLink _previous; | 5 _LinkedListLink _previous; |
6 LinkedList() { | 6 LinkedList() { |
7 _next = _previous = this; | 7 _next = _previous = this; |
8 } | 8 } |
9 void addFirst(E entry) { | 9 void addFirst(E entry) { |
10 _insertAfter(this, entry); | 10 _insertAfter(this, entry); |
11 } | 11 } |
12 void add(E entry) { | 12 void add(E entry) { |
13 _insertAfter(_previous, entry); | 13 _insertAfter(_previous, entry); |
14 } | 14 } |
15 void addAll(Iterable<E> entries) { | 15 void addAll(Iterable<E> entries) { |
16 entries.forEach((entry) => _insertAfter(_previous, DDC$RT.cast(entry, dynamic,
E, "CastGeneral", """line 65, column 56 of dart:collection/linked_list.dart: ""
", entry is E, false))); | 16 entries.forEach((entry) => _insertAfter(_previous, DEVC$RT.cast(entry, dynamic
, E, "CastGeneral", """line 65, column 56 of dart:collection/linked_list.dart: "
"", entry is E, false))); |
17 } | 17 } |
18 bool remove(E entry) { | 18 bool remove(E entry) { |
19 if (entry._list != this) return false; | 19 if (entry._list != this) return false; |
20 _unlink(entry); | 20 _unlink(entry); |
21 return true; | 21 return true; |
22 } | 22 } |
23 Iterator<E> get iterator => new _LinkedListIterator<E>(this); | 23 Iterator<E> get iterator => new _LinkedListIterator<E>(this); |
24 int get length => _length; | 24 int get length => _length; |
25 void clear() { | 25 void clear() { |
26 _modificationCount++; | 26 _modificationCount++; |
27 _LinkedListLink next = _next; | 27 _LinkedListLink next = _next; |
28 while (!identical(next, this)) { | 28 while (!identical(next, this)) { |
29 E entry = DDC$RT.cast(next, _LinkedListLink, E, "CastGeneral", """line 93, c
olumn 17 of dart:collection/linked_list.dart: """, next is E, false); | 29 E entry = DEVC$RT.cast(next, _LinkedListLink, E, "CastGeneral", """line 93,
column 17 of dart:collection/linked_list.dart: """, next is E, false); |
30 next = entry._next; | 30 next = entry._next; |
31 entry._next = entry._previous = entry._list = null; | 31 entry._next = entry._previous = entry._list = null; |
32 } | 32 } |
33 _next = _previous = this; | 33 _next = _previous = this; |
34 _length = 0; | 34 _length = 0; |
35 } | 35 } |
36 E get first { | 36 E get first { |
37 if (identical(_next, this)) { | 37 if (identical(_next, this)) { |
38 throw new StateError('No such element'); | 38 throw new StateError('No such element'); |
39 } | 39 } |
40 return DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 105, col
umn 12 of dart:collection/linked_list.dart: """, _next is E, false); | 40 return DEVC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 105, co
lumn 12 of dart:collection/linked_list.dart: """, _next is E, false); |
41 } | 41 } |
42 E get last { | 42 E get last { |
43 if (identical(_previous, this)) { | 43 if (identical(_previous, this)) { |
44 throw new StateError('No such element'); | 44 throw new StateError('No such element'); |
45 } | 45 } |
46 return DDC$RT.cast(_previous, _LinkedListLink, E, "CastGeneral", """line 112,
column 12 of dart:collection/linked_list.dart: """, _previous is E, false); | 46 return DEVC$RT.cast(_previous, _LinkedListLink, E, "CastGeneral", """line 112
, column 12 of dart:collection/linked_list.dart: """, _previous is E, false); |
47 } | 47 } |
48 E get single { | 48 E get single { |
49 if (identical(_previous, this)) { | 49 if (identical(_previous, this)) { |
50 throw new StateError('No such element'); | 50 throw new StateError('No such element'); |
51 } | 51 } |
52 if (!identical(_previous, _next)) { | 52 if (!identical(_previous, _next)) { |
53 throw new StateError('Too many elements'); | 53 throw new StateError('Too many elements'); |
54 } | 54 } |
55 return DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 122, col
umn 12 of dart:collection/linked_list.dart: """, _next is E, false); | 55 return DEVC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 122, co
lumn 12 of dart:collection/linked_list.dart: """, _next is E, false); |
56 } | 56 } |
57 void forEach(void action(E entry)) { | 57 void forEach(void action(E entry)) { |
58 int modificationCount = _modificationCount; | 58 int modificationCount = _modificationCount; |
59 _LinkedListLink current = _next; | 59 _LinkedListLink current = _next; |
60 while (!identical(current, this)) { | 60 while (!identical(current, this)) { |
61 action(DDC$RT.cast(current, _LinkedListLink, E, "CastGeneral", """line 134,
column 14 of dart:collection/linked_list.dart: """, current is E, false)); | 61 action(DEVC$RT.cast(current, _LinkedListLink, E, "CastGeneral", """line 134,
column 14 of dart:collection/linked_list.dart: """, current is E, false)); |
62 if (modificationCount != _modificationCount) { | 62 if (modificationCount != _modificationCount) { |
63 throw new ConcurrentModificationError(this); | 63 throw new ConcurrentModificationError(this); |
64 } | 64 } |
65 current = current._next; | 65 current = current._next; |
66 } | 66 } |
67 } | 67 } |
68 bool get isEmpty => _length == 0; | 68 bool get isEmpty => _length == 0; |
69 void _insertAfter(_LinkedListLink entry, E newEntry) { | 69 void _insertAfter(_LinkedListLink entry, E newEntry) { |
70 if (newEntry.list != null) { | 70 if (newEntry.list != null) { |
71 throw new StateError('LinkedListEntry is already in a LinkedList'); | 71 throw new StateError('LinkedListEntry is already in a LinkedList'); |
(...skipping 23 matching lines...) Expand all Loading... |
95 _LinkedListIterator(LinkedList<E> list) : _list = list, _modificationCount = li
st._modificationCount, _next = list._next; | 95 _LinkedListIterator(LinkedList<E> list) : _list = list, _modificationCount = li
st._modificationCount, _next = list._next; |
96 E get current => _current; | 96 E get current => _current; |
97 bool moveNext() { | 97 bool moveNext() { |
98 if (identical(_next, _list)) { | 98 if (identical(_next, _list)) { |
99 _current = null; | 99 _current = null; |
100 return false; | 100 return false; |
101 } | 101 } |
102 if (_modificationCount != _list._modificationCount) { | 102 if (_modificationCount != _list._modificationCount) { |
103 throw new ConcurrentModificationError(this); | 103 throw new ConcurrentModificationError(this); |
104 } | 104 } |
105 _current = DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 192, c
olumn 16 of dart:collection/linked_list.dart: """, _next is E, false); | 105 _current = DEVC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 192,
column 16 of dart:collection/linked_list.dart: """, _next is E, false); |
106 _next = _next._next; | 106 _next = _next._next; |
107 return true; | 107 return true; |
108 } | 108 } |
109 } | 109 } |
110 class _LinkedListLink {_LinkedListLink _next; | 110 class _LinkedListLink {_LinkedListLink _next; |
111 _LinkedListLink _previous; | 111 _LinkedListLink _previous; |
112 } | 112 } |
113 abstract class LinkedListEntry<E extends LinkedListEntry<E>> implements _Linked
ListLink {LinkedList<E> _list; | 113 abstract class LinkedListEntry<E extends LinkedListEntry<E>> implements _Linked
ListLink {LinkedList<E> _list; |
114 _LinkedListLink _next; | 114 _LinkedListLink _next; |
115 _LinkedListLink _previous; | 115 _LinkedListLink _previous; |
116 LinkedList<E> get list => _list; | 116 LinkedList<E> get list => _list; |
117 void unlink() { | 117 void unlink() { |
118 _list._unlink(this); | 118 _list._unlink(this); |
119 } | 119 } |
120 E get next { | 120 E get next { |
121 if (identical(_next, _list)) return null; | 121 if (identical(_next, _list)) return null; |
122 E result = DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 249, c
olumn 16 of dart:collection/linked_list.dart: """, _next is E, false); | 122 E result = DEVC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 249,
column 16 of dart:collection/linked_list.dart: """, _next is E, false); |
123 return result; | 123 return result; |
124 } | 124 } |
125 E get previous { | 125 E get previous { |
126 if (identical(_previous, _list)) return null; | 126 if (identical(_previous, _list)) return null; |
127 return DDC$RT.cast(_previous, _LinkedListLink, E, "CastUser", """line 261, colu
mn 12 of dart:collection/linked_list.dart: """, _previous is E, false); | 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 } | 128 } |
129 void insertAfter(E entry) { | 129 void insertAfter(E entry) { |
130 _list._insertAfter(this, entry); | 130 _list._insertAfter(this, entry); |
131 } | 131 } |
132 void insertBefore(E entry) { | 132 void insertBefore(E entry) { |
133 _list._insertAfter(_previous, entry); | 133 _list._insertAfter(_previous, entry); |
134 } | 134 } |
135 } | 135 } |
OLD | NEW |