OLD | NEW |
1 part of angular.watch_group; | 1 part of angular.watch_group; |
2 | 2 |
3 | 3 |
4 class _LinkedListItem<I extends _LinkedListItem> { | 4 class _LinkedListItem<I extends _LinkedListItem> { |
5 I _previous, _next; | 5 I _previous, _next; |
6 } | 6 } |
7 | 7 |
8 class _LinkedList<L extends _LinkedList> { | 8 class _LinkedList<L extends _LinkedListItem> { |
9 L _head, _tail; | 9 L _head, _tail; |
10 | 10 |
11 static _Handler _add(_Handler list, _LinkedListItem item) { | 11 static _Handler _add(_Handler list, _LinkedListItem item) { |
12 assert(item._next == null); | 12 assert(item._next == null); |
13 assert(item._previous == null); | 13 assert(item._previous == null); |
14 if (list._tail == null) { | 14 if (list._tail == null) { |
15 list._head = list._tail = item; | 15 list._head = list._tail = item; |
16 } else { | 16 } else { |
17 item._previous = list._tail; | 17 item._previous = list._tail; |
18 list._tail._next = item; | 18 list._tail._next = item; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 if (next == null) list._watchTail = previous; else next._previousWatch =
previous; | 85 if (next == null) list._watchTail = previous; else next._previousWatch =
previous; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 abstract class _EvalWatchList { | 89 abstract class _EvalWatchList { |
90 _EvalWatchRecord _evalWatchHead, _evalWatchTail; | 90 _EvalWatchRecord _evalWatchHead, _evalWatchTail; |
91 _EvalWatchRecord get _marker; | 91 _EvalWatchRecord get _marker; |
92 | 92 |
93 static _EvalWatchRecord _add(_EvalWatchList list, _EvalWatchRecord item) { | 93 static _EvalWatchRecord _add(_EvalWatchList list, _EvalWatchRecord item) { |
94 assert(item._nextEvalWatch == null); | 94 assert(item._nextEvalWatch == null); |
95 assert(item._previousEvalWatch == null); | 95 assert(item._prevEvalWatch == null); |
96 var prev = list._evalWatchTail; | 96 var prev = list._evalWatchTail; |
97 var next = prev._nextEvalWatch; | 97 var next = prev._nextEvalWatch; |
98 | 98 |
99 if (prev == list._marker) { | 99 if (prev == list._marker) { |
100 list._evalWatchHead = list._evalWatchTail = item; | 100 list._evalWatchHead = list._evalWatchTail = item; |
101 prev = prev._previousEvalWatch; | 101 prev = prev._prevEvalWatch; |
| 102 list._marker._prevEvalWatch = null; |
| 103 list._marker._nextEvalWatch = null; |
102 } | 104 } |
103 item._nextEvalWatch = next; | 105 item._nextEvalWatch = next; |
104 item._previousEvalWatch = prev; | 106 item._prevEvalWatch = prev; |
105 | 107 |
106 if (prev != null) prev._nextEvalWatch = item; | 108 if (prev != null) prev._nextEvalWatch = item; |
107 if (next != null) next._previousEvalWatch = item; | 109 if (next != null) next._prevEvalWatch = item; |
108 | 110 |
109 return list._evalWatchTail = item; | 111 return list._evalWatchTail = item; |
110 } | 112 } |
111 | 113 |
112 static bool _isEmpty(_EvalWatchList list) => list._evalWatchHead == null; | 114 static bool _isEmpty(_EvalWatchList list) => list._evalWatchHead == null; |
113 | 115 |
114 static void _remove(_EvalWatchList list, _EvalWatchRecord item) { | 116 static void _remove(_EvalWatchList list, _EvalWatchRecord item) { |
115 assert(item.watchGrp == list); | 117 assert(item.watchGrp == list); |
116 var prev = item._previousEvalWatch; | 118 var prev = item._prevEvalWatch; |
117 var next = item._nextEvalWatch; | 119 var next = item._nextEvalWatch; |
118 | 120 |
119 if (list._evalWatchHead == list._evalWatchTail) { | 121 if (list._evalWatchHead == list._evalWatchTail) { |
120 list._evalWatchHead = list._evalWatchTail = list._marker; | 122 list._evalWatchHead = list._evalWatchTail = list._marker; |
121 list._marker | 123 list._marker |
122 .._nextEvalWatch = next | 124 .._nextEvalWatch = next |
123 .._previousEvalWatch = prev; | 125 .._prevEvalWatch = prev; |
124 if (prev != null) prev._nextEvalWatch = list._marker; | 126 if (prev != null) prev._nextEvalWatch = list._marker; |
125 if (next != null) next._previousEvalWatch = list._marker; | 127 if (next != null) next._prevEvalWatch = list._marker; |
126 } else { | 128 } else { |
127 if (item == list._evalWatchHead) list._evalWatchHead = next; | 129 if (item == list._evalWatchHead) list._evalWatchHead = next; |
128 if (item == list._evalWatchTail) list._evalWatchTail = prev; | 130 if (item == list._evalWatchTail) list._evalWatchTail = prev; |
129 if (prev != null) prev._nextEvalWatch = next; | 131 if (prev != null) prev._nextEvalWatch = next; |
130 if (next != null) next._previousEvalWatch = prev; | 132 if (next != null) next._prevEvalWatch = prev; |
131 } | 133 } |
132 } | 134 } |
133 } | 135 } |
134 | 136 |
135 class _WatchGroupList { | 137 class _WatchGroupList { |
136 WatchGroup _watchGroupHead, _watchGroupTail; | 138 WatchGroup _watchGroupHead, _watchGroupTail; |
137 | 139 |
138 static WatchGroup _add(_WatchGroupList list, WatchGroup item) { | 140 static WatchGroup _add(_WatchGroupList list, WatchGroup item) { |
139 assert(item._nextWatchGroup == null); | 141 assert(item._nextWatchGroup == null); |
140 assert(item._previousWatchGroup == null); | 142 assert(item._prevWatchGroup == null); |
141 if (list._watchGroupTail == null) { | 143 if (list._watchGroupTail == null) { |
142 list._watchGroupHead = list._watchGroupTail = item; | 144 list._watchGroupHead = list._watchGroupTail = item; |
143 } else { | 145 } else { |
144 item._previousWatchGroup = list._watchGroupTail; | 146 item._prevWatchGroup = list._watchGroupTail; |
145 list._watchGroupTail._nextWatchGroup = item; | 147 list._watchGroupTail._nextWatchGroup = item; |
146 list._watchGroupTail = item; | 148 list._watchGroupTail = item; |
147 } | 149 } |
148 return item; | 150 return item; |
149 } | 151 } |
150 | 152 |
151 static bool _isEmpty(_WatchGroupList list) => list._watchGroupHead == null; | 153 static bool _isEmpty(_WatchGroupList list) => list._watchGroupHead == null; |
152 | 154 |
153 static void _remove(_WatchGroupList list, WatchGroup item) { | 155 static void _remove(_WatchGroupList list, WatchGroup item) { |
154 var previous = item._previousWatchGroup; | 156 var previous = item._prevWatchGroup; |
155 var next = item._nextWatchGroup; | 157 var next = item._nextWatchGroup; |
156 | 158 |
157 if (previous == null) list._watchGroupHead = next; else previous._nextWa
tchGroup = next; | 159 if (previous == null) list._watchGroupHead = next; else previous._nextWa
tchGroup = next; |
158 if (next == null) list._watchGroupTail = previous; else next._previousWa
tchGroup = previous; | 160 if (next == null) list._watchGroupTail = previous; else next._prevWatchG
roup = previous; |
159 } | 161 } |
160 } | 162 } |
OLD | NEW |