| OLD | NEW |
| 1 part of dart.collection; | 1 part of dart.collection; |
| 2 | 2 class LinkedList<E extends LinkedListEntry<E>> extends IterableBase<E> implemen
ts _LinkedListLink {int _modificationCount = 0; |
| 3 class LinkedList<E extends LinkedListEntry<E>> extends IterableBase<E> | 3 int _length = 0; |
| 4 implements _LinkedListLink { | 4 _LinkedListLink _next; |
| 5 int _modificationCount = 0; | 5 _LinkedListLink _previous; |
| 6 int _length = 0; | 6 LinkedList() { |
| 7 _LinkedListLink _next; | 7 _next = _previous = this; |
| 8 _LinkedListLink _previous; | |
| 9 LinkedList() { | |
| 10 _next = _previous = this; | |
| 11 } | 8 } |
| 12 void addFirst(E entry) { | 9 void addFirst(E entry) { |
| 13 _insertAfter(this, entry); | 10 _insertAfter(this, entry); |
| 14 } | 11 } |
| 15 void add(E entry) { | 12 void add(E entry) { |
| 16 _insertAfter(_previous, entry); | 13 _insertAfter(_previous, entry); |
| 17 } | 14 } |
| 18 void addAll(Iterable<E> entries) { | 15 void addAll(Iterable<E> entries) { |
| 19 entries.forEach((entry) => _insertAfter(_previous, DDC$RT.cast(entry, | 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))); |
| 20 dynamic, E, "CastGeneral", | |
| 21 """line 65, column 56 of dart:collection/linked_list.dart: """, | |
| 22 entry is E, false))); | |
| 23 } | 17 } |
| 24 bool remove(E entry) { | 18 bool remove(E entry) { |
| 25 if (entry._list != this) return false; | 19 if (entry._list != this) return false; |
| 26 _unlink(entry); | 20 _unlink(entry); |
| 27 return true; | 21 return true; |
| 28 } | 22 } |
| 29 Iterator<E> get iterator => new _LinkedListIterator<E>(this); | 23 Iterator<E> get iterator => new _LinkedListIterator<E>(this); |
| 30 int get length => _length; | 24 int get length => _length; |
| 31 void clear() { | 25 void clear() { |
| 32 _modificationCount++; | 26 _modificationCount++; |
| 33 _LinkedListLink next = _next; | 27 _LinkedListLink next = _next; |
| 34 while (!identical(next, this)) { | 28 while (!identical(next, this)) { |
| 35 E entry = DDC$RT.cast(next, _LinkedListLink, E, "CastGeneral", | 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); |
| 36 """line 93, column 17 of dart:collection/linked_list.dart: """, | 30 next = entry._next; |
| 37 next is E, false); | 31 entry._next = entry._previous = entry._list = null; |
| 38 next = entry._next; | |
| 39 entry._next = entry._previous = entry._list = null; | |
| 40 } | 32 } |
| 41 _next = _previous = this; | 33 _next = _previous = this; |
| 42 _length = 0; | 34 _length = 0; |
| 43 } | 35 } |
| 44 E get first { | 36 E get first { |
| 45 if (identical(_next, this)) { | 37 if (identical(_next, this)) { |
| 46 throw new StateError('No such element'); | 38 throw new StateError('No such element'); |
| 47 } | 39 } |
| 48 return DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", | 40 return DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 105, col
umn 12 of dart:collection/linked_list.dart: """, _next is E, false); |
| 49 """line 105, column 12 of dart:collection/linked_list.dart: """, | |
| 50 _next is E, false); | |
| 51 } | 41 } |
| 52 E get last { | 42 E get last { |
| 53 if (identical(_previous, this)) { | 43 if (identical(_previous, this)) { |
| 54 throw new StateError('No such element'); | 44 throw new StateError('No such element'); |
| 55 } | 45 } |
| 56 return DDC$RT.cast(_previous, _LinkedListLink, E, "CastGeneral", | 46 return DDC$RT.cast(_previous, _LinkedListLink, E, "CastGeneral", """line 112,
column 12 of dart:collection/linked_list.dart: """, _previous is E, false); |
| 57 """line 112, column 12 of dart:collection/linked_list.dart: """, | |
| 58 _previous is E, false); | |
| 59 } | 47 } |
| 60 E get single { | 48 E get single { |
| 61 if (identical(_previous, this)) { | 49 if (identical(_previous, this)) { |
| 62 throw new StateError('No such element'); | 50 throw new StateError('No such element'); |
| 63 } | 51 } |
| 64 if (!identical(_previous, _next)) { | 52 if (!identical(_previous, _next)) { |
| 65 throw new StateError('Too many elements'); | 53 throw new StateError('Too many elements'); |
| 66 } | 54 } |
| 67 return DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", | 55 return DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 122, col
umn 12 of dart:collection/linked_list.dart: """, _next is E, false); |
| 68 """line 122, column 12 of dart:collection/linked_list.dart: """, | |
| 69 _next is E, false); | |
| 70 } | 56 } |
| 71 void forEach(void action(E entry)) { | 57 void forEach(void action(E entry)) { |
| 72 int modificationCount = _modificationCount; | 58 int modificationCount = _modificationCount; |
| 73 _LinkedListLink current = _next; | 59 _LinkedListLink current = _next; |
| 74 while (!identical(current, this)) { | 60 while (!identical(current, this)) { |
| 75 action(DDC$RT.cast(current, _LinkedListLink, E, "CastGeneral", | 61 action(DDC$RT.cast(current, _LinkedListLink, E, "CastGeneral", """line 134,
column 14 of dart:collection/linked_list.dart: """, current is E, false)); |
| 76 """line 134, column 14 of dart:collection/linked_list.dart: """, | 62 if (modificationCount != _modificationCount) { |
| 77 current is E, false)); | 63 throw new ConcurrentModificationError(this); |
| 78 if (modificationCount != _modificationCount) { | |
| 79 throw new ConcurrentModificationError(this); | |
| 80 } | 64 } |
| 81 current = current._next; | 65 current = current._next; |
| 82 } | 66 } |
| 83 } | 67 } |
| 84 bool get isEmpty => _length == 0; | 68 bool get isEmpty => _length == 0; |
| 85 void _insertAfter(_LinkedListLink entry, E newEntry) { | 69 void _insertAfter(_LinkedListLink entry, E newEntry) { |
| 86 if (newEntry.list != null) { | 70 if (newEntry.list != null) { |
| 87 throw new StateError('LinkedListEntry is already in a LinkedList'); | 71 throw new StateError('LinkedListEntry is already in a LinkedList'); |
| 88 } | 72 } |
| 89 _modificationCount++; | 73 _modificationCount++; |
| 90 newEntry._list = this; | 74 newEntry._list = this; |
| 91 var predecessor = entry; | 75 var predecessor = entry; |
| 92 var successor = entry._next; | 76 var successor = entry._next; |
| 93 successor._previous = newEntry; | 77 successor._previous = newEntry; |
| 94 newEntry._previous = predecessor; | 78 newEntry._previous = predecessor; |
| 95 newEntry._next = successor; | 79 newEntry._next = successor; |
| 96 predecessor._next = newEntry; | 80 predecessor._next = newEntry; |
| 97 _length++; | 81 _length++; |
| 98 } | 82 } |
| 99 void _unlink(LinkedListEntry<E> entry) { | 83 void _unlink(LinkedListEntry<E> entry) { |
| 100 _modificationCount++; | 84 _modificationCount++; |
| 101 entry._next._previous = entry._previous; | 85 entry._next._previous = entry._previous; |
| 102 entry._previous._next = entry._next; | 86 entry._previous._next = entry._next; |
| 103 _length--; | 87 _length--; |
| 104 entry._list = entry._next = entry._previous = null; | 88 entry._list = entry._next = entry._previous = null; |
| 105 } | 89 } |
| 106 } | 90 } |
| 107 class _LinkedListIterator<E extends LinkedListEntry<E>> implements Iterator<E> { | 91 class _LinkedListIterator<E extends LinkedListEntry<E>> implements Iterator<E>
{final LinkedList<E> _list; |
| 108 final LinkedList<E> _list; | 92 final int _modificationCount; |
| 109 final int _modificationCount; | 93 E _current; |
| 110 E _current; | 94 _LinkedListLink _next; |
| 111 _LinkedListLink _next; | 95 _LinkedListIterator(LinkedList<E> list) : _list = list, _modificationCount = li
st._modificationCount, _next = list._next; |
| 112 _LinkedListIterator(LinkedList<E> list) | 96 E get current => _current; |
| 113 : _list = list, | 97 bool moveNext() { |
| 114 _modificationCount = list._modificationCount, | 98 if (identical(_next, _list)) { |
| 115 _next = list._next; | 99 _current = null; |
| 116 E get current => _current; | 100 return false; |
| 117 bool moveNext() { | |
| 118 if (identical(_next, _list)) { | |
| 119 _current = null; | |
| 120 return false; | |
| 121 } | |
| 122 if (_modificationCount != _list._modificationCount) { | |
| 123 throw new ConcurrentModificationError(this); | |
| 124 } | |
| 125 _current = DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", | |
| 126 """line 192, column 16 of dart:collection/linked_list.dart: """, | |
| 127 _next is E, false); | |
| 128 _next = _next._next; | |
| 129 return true; | |
| 130 } | 101 } |
| 102 if (_modificationCount != _list._modificationCount) { |
| 103 throw new ConcurrentModificationError(this); |
| 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); |
| 106 _next = _next._next; |
| 107 return true; |
| 131 } | 108 } |
| 132 class _LinkedListLink { | |
| 133 _LinkedListLink _next; | |
| 134 _LinkedListLink _previous; | |
| 135 } | 109 } |
| 136 abstract class LinkedListEntry<E extends LinkedListEntry<E>> | 110 class _LinkedListLink {_LinkedListLink _next; |
| 137 implements _LinkedListLink { | 111 _LinkedListLink _previous; |
| 138 LinkedList<E> _list; | |
| 139 _LinkedListLink _next; | |
| 140 _LinkedListLink _previous; | |
| 141 LinkedList<E> get list => _list; | |
| 142 void unlink() { | |
| 143 _list._unlink(this); | |
| 144 } | |
| 145 E get next { | |
| 146 if (identical(_next, _list)) return null; | |
| 147 E result = DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", | |
| 148 """line 249, column 16 of dart:collection/linked_list.dart: """, | |
| 149 _next is E, false); | |
| 150 return result; | |
| 151 } | |
| 152 E get previous { | |
| 153 if (identical(_previous, _list)) return null; | |
| 154 return DDC$RT.cast(_previous, _LinkedListLink, E, "CastUser", | |
| 155 """line 261, column 12 of dart:collection/linked_list.dart: """, | |
| 156 _previous is E, false); | |
| 157 } | |
| 158 void insertAfter(E entry) { | |
| 159 _list._insertAfter(this, entry); | |
| 160 } | |
| 161 void insertBefore(E entry) { | |
| 162 _list._insertAfter(_previous, entry); | |
| 163 } | |
| 164 } | 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 = DDC$RT.cast(_next, _LinkedListLink, E, "CastGeneral", """line 249, c
olumn 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 DDC$RT.cast(_previous, _LinkedListLink, E, "CastUser", """line 261, colu
mn 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 } |
| OLD | NEW |