OLD | NEW |
1 part of dart.collection; | 1 part of dart.collection; |
2 abstract class Queue<E> implements Iterable<E>, EfficientLength {factory Queue(
) = ListQueue<E>; | 2 abstract class Queue<E> implements Iterable<E>, EfficientLength {factory Queue(
) = ListQueue<E>; |
3 factory Queue.from(Iterable elements) = ListQueue<E>.from; | 3 factory Queue.from(Iterable elements) = ListQueue<E>.from; |
4 E removeFirst(); | 4 E removeFirst(); |
5 E removeLast(); | 5 E removeLast(); |
6 void addFirst(E value); | 6 void addFirst(E value); |
7 void addLast(E value); | 7 void addLast(E value); |
8 void add(E value); | 8 void add(E value); |
9 bool remove(Object object); | 9 bool remove(Object object); |
10 void addAll(Iterable<E> iterable); | 10 void addAll(Iterable<E> iterable); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 class DoubleLinkedQueue<E> extends IterableBase<E> implements Queue<E> {_Double
LinkedQueueEntrySentinel<E> _sentinel; | 69 class DoubleLinkedQueue<E> extends IterableBase<E> implements Queue<E> {_Double
LinkedQueueEntrySentinel<E> _sentinel; |
70 int _elementCount = 0; | 70 int _elementCount = 0; |
71 DoubleLinkedQueue() { | 71 DoubleLinkedQueue() { |
72 _sentinel = new _DoubleLinkedQueueEntrySentinel<E>(); | 72 _sentinel = new _DoubleLinkedQueueEntrySentinel<E>(); |
73 } | 73 } |
74 factory DoubleLinkedQueue.from(Iterable elements) { | 74 factory DoubleLinkedQueue.from(Iterable elements) { |
75 Queue<E> list = ((__x17) => DEVC$RT.cast(__x17, DEVC$RT.type((DoubleLinkedQueue<
dynamic> _) { | 75 Queue<E> list = ((__x17) => DEVC$RT.cast(__x17, DEVC$RT.type((DoubleLinkedQueue<
dynamic> _) { |
76 } | 76 } |
77 ), DEVC$RT.type((Queue<E> _) { | 77 ), DEVC$RT.type((Queue<E> _) { |
78 } | 78 } |
79 ), "CastExact", """line 207, column 21 of dart:collection/queue.dart: """, __x17
is Queue<E>, false))(new DoubleLinkedQueue()); | 79 ), "InferableAllocation", """line 207, column 21 of dart:collection/queue.dart:
""", __x17 is Queue<E>, false))(new DoubleLinkedQueue()); |
80 for (final E e in elements) { | 80 for (final E e in elements) { |
81 list.addLast(e); | 81 list.addLast(e); |
82 } | 82 } |
83 return DEVC$RT.cast(list, DEVC$RT.type((Queue<E> _) { | 83 return DEVC$RT.cast(list, DEVC$RT.type((Queue<E> _) { |
84 } | 84 } |
85 ), DEVC$RT.type((DoubleLinkedQueue<E> _) { | 85 ), DEVC$RT.type((DoubleLinkedQueue<E> _) { |
86 } | 86 } |
87 ), "CastGeneral", """line 211, column 12 of dart:collection/queue.dart: """, lis
t is DoubleLinkedQueue<E>, false); | 87 ), "CompositeCast", """line 211, column 12 of dart:collection/queue.dart: """, l
ist is DoubleLinkedQueue<E>, false); |
88 } | 88 } |
89 int get length => _elementCount; | 89 int get length => _elementCount; |
90 void addLast(E value) { | 90 void addLast(E value) { |
91 _sentinel.prepend(value); | 91 _sentinel.prepend(value); |
92 _elementCount++; | 92 _elementCount++; |
93 } | 93 } |
94 void addFirst(E value) { | 94 void addFirst(E value) { |
95 _sentinel.append(value); | 95 _sentinel.append(value); |
96 _elementCount++; | 96 _elementCount++; |
97 } | 97 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 213 } |
214 assert (_isPowerOf2(initialCapacity)); _table = new List<E>(initialCapacity); | 214 assert (_isPowerOf2(initialCapacity)); _table = new List<E>(initialCapacity); |
215 } | 215 } |
216 factory ListQueue.from(Iterable elements) { | 216 factory ListQueue.from(Iterable elements) { |
217 if (elements is List) { | 217 if (elements is List) { |
218 int length = elements.length; | 218 int length = elements.length; |
219 ListQueue<E> queue = ((__x18) => DEVC$RT.cast(__x18, DEVC$RT.type((ListQueue<dy
namic> _) { | 219 ListQueue<E> queue = ((__x18) => DEVC$RT.cast(__x18, DEVC$RT.type((ListQueue<dy
namic> _) { |
220 } | 220 } |
221 ), DEVC$RT.type((ListQueue<E> _) { | 221 ), DEVC$RT.type((ListQueue<E> _) { |
222 } | 222 } |
223 ), "CastExact", """line 399, column 28 of dart:collection/queue.dart: """, __x18
is ListQueue<E>, false))(new ListQueue(length + 1)); | 223 ), "InferableAllocation", """line 399, column 28 of dart:collection/queue.dart:
""", __x18 is ListQueue<E>, false))(new ListQueue(length + 1)); |
224 assert (queue._table.length > length); List sourceList = elements; | 224 assert (queue._table.length > length); List sourceList = elements; |
225 queue._table.setRange(0, length, DEVC$RT.cast(sourceList, DEVC$RT.type((List<dy
namic> _) { | 225 queue._table.setRange(0, length, DEVC$RT.cast(sourceList, DEVC$RT.type((List<dy
namic> _) { |
226 } | 226 } |
227 ), DEVC$RT.type((Iterable<E> _) { | 227 ), DEVC$RT.type((Iterable<E> _) { |
228 } | 228 } |
229 ), "CastDynamic", """line 402, column 40 of dart:collection/queue.dart: """, sou
rceList is Iterable<E>, false), 0); | 229 ), "CompositeCast", """line 402, column 40 of dart:collection/queue.dart: """, s
ourceList is Iterable<E>, false), 0); |
230 queue._tail = length; | 230 queue._tail = length; |
231 return queue; | 231 return queue; |
232 } | 232 } |
233 else { | 233 else { |
234 int capacity = _INITIAL_CAPACITY; | 234 int capacity = _INITIAL_CAPACITY; |
235 if (elements is EfficientLength) { | 235 if (elements is EfficientLength) { |
236 capacity = elements.length; | 236 capacity = elements.length; |
237 } | 237 } |
238 ListQueue<E> result = new ListQueue<E>(capacity); | 238 ListQueue<E> result = new ListQueue<E>(capacity); |
239 for (final E element in elements) { | 239 for (final E element in elements) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 284 } |
285 void add(E element) { | 285 void add(E element) { |
286 _add(element); | 286 _add(element); |
287 } | 287 } |
288 void addAll(Iterable<E> elements) { | 288 void addAll(Iterable<E> elements) { |
289 if (elements is List) { | 289 if (elements is List) { |
290 List list = DEVC$RT.cast(elements, DEVC$RT.type((Iterable<E> _) { | 290 List list = DEVC$RT.cast(elements, DEVC$RT.type((Iterable<E> _) { |
291 } | 291 } |
292 ), DEVC$RT.type((List<dynamic> _) { | 292 ), DEVC$RT.type((List<dynamic> _) { |
293 } | 293 } |
294 ), "CastGeneral", """line 474, column 19 of dart:collection/queue.dart: """, ele
ments is List<dynamic>, true); | 294 ), "AssignmentCast", """line 474, column 19 of dart:collection/queue.dart: """,
elements is List<dynamic>, true); |
295 int addCount = list.length; | 295 int addCount = list.length; |
296 int length = this.length; | 296 int length = this.length; |
297 if (length + addCount >= _table.length) { | 297 if (length + addCount >= _table.length) { |
298 _preGrow(length + addCount); | 298 _preGrow(length + addCount); |
299 _table.setRange(length, length + addCount, DEVC$RT.cast(list, DEVC$RT.type((Lis
t<dynamic> _) { | 299 _table.setRange(length, length + addCount, DEVC$RT.cast(list, DEVC$RT.type((Lis
t<dynamic> _) { |
300 } | 300 } |
301 ), DEVC$RT.type((Iterable<E> _) { | 301 ), DEVC$RT.type((Iterable<E> _) { |
302 } | 302 } |
303 ), "CastDynamic", """line 480, column 52 of dart:collection/queue.dart: """, lis
t is Iterable<E>, false), 0); | 303 ), "CompositeCast", """line 480, column 52 of dart:collection/queue.dart: """, l
ist is Iterable<E>, false), 0); |
304 _tail += addCount; | 304 _tail += addCount; |
305 } | 305 } |
306 else { | 306 else { |
307 int endSpace = _table.length - _tail; | 307 int endSpace = _table.length - _tail; |
308 if (addCount < endSpace) { | 308 if (addCount < endSpace) { |
309 _table.setRange(_tail, _tail + addCount, DEVC$RT.cast(list, DEVC$RT.type((List<d
ynamic> _) { | 309 _table.setRange(_tail, _tail + addCount, DEVC$RT.cast(list, DEVC$RT.type((List<d
ynamic> _) { |
310 } | 310 } |
311 ), DEVC$RT.type((Iterable<E> _) { | 311 ), DEVC$RT.type((Iterable<E> _) { |
312 } | 312 } |
313 ), "CastDynamic", """line 486, column 52 of dart:collection/queue.dart: """, lis
t is Iterable<E>, false), 0); | 313 ), "CompositeCast", """line 486, column 52 of dart:collection/queue.dart: """, l
ist is Iterable<E>, false), 0); |
314 _tail += addCount; | 314 _tail += addCount; |
315 } | 315 } |
316 else { | 316 else { |
317 int preSpace = addCount - endSpace; | 317 int preSpace = addCount - endSpace; |
318 _table.setRange(_tail, _tail + endSpace, DEVC$RT.cast(list, DEVC$RT.type((List<
dynamic> _) { | 318 _table.setRange(_tail, _tail + endSpace, DEVC$RT.cast(list, DEVC$RT.type((List<
dynamic> _) { |
319 } | 319 } |
320 ), DEVC$RT.type((Iterable<E> _) { | 320 ), DEVC$RT.type((Iterable<E> _) { |
321 } | 321 } |
322 ), "CastDynamic", """line 490, column 52 of dart:collection/queue.dart: """, lis
t is Iterable<E>, false), 0); | 322 ), "CompositeCast", """line 490, column 52 of dart:collection/queue.dart: """, l
ist is Iterable<E>, false), 0); |
323 _table.setRange(0, preSpace, DEVC$RT.cast(list, DEVC$RT.type((List<dynamic> _)
{ | 323 _table.setRange(0, preSpace, DEVC$RT.cast(list, DEVC$RT.type((List<dynamic> _)
{ |
324 } | 324 } |
325 ), DEVC$RT.type((Iterable<E> _) { | 325 ), DEVC$RT.type((Iterable<E> _) { |
326 } | 326 } |
327 ), "CastDynamic", """line 491, column 40 of dart:collection/queue.dart: """, lis
t is Iterable<E>, false), endSpace); | 327 ), "CompositeCast", """line 491, column 40 of dart:collection/queue.dart: """, l
ist is Iterable<E>, false), endSpace); |
328 _tail = preSpace; | 328 _tail = preSpace; |
329 } | 329 } |
330 } | 330 } |
331 _modificationCount++; | 331 _modificationCount++; |
332 } | 332 } |
333 else { | 333 else { |
334 for (E element in elements) _add(element); | 334 for (E element in elements) _add(element); |
335 } | 335 } |
336 } | 336 } |
337 bool remove(Object object) { | 337 bool remove(Object object) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 int _position; | 487 int _position; |
488 E _current; | 488 E _current; |
489 _ListQueueIterator(ListQueue queue) : _queue = queue, _end = queue._tail, _modi
ficationCount = queue._modificationCount, _position = queue._head; | 489 _ListQueueIterator(ListQueue queue) : _queue = queue, _end = queue._tail, _modi
ficationCount = queue._modificationCount, _position = queue._head; |
490 E get current => _current; | 490 E get current => _current; |
491 bool moveNext() { | 491 bool moveNext() { |
492 _queue._checkModification(_modificationCount); | 492 _queue._checkModification(_modificationCount); |
493 if (_position == _end) { | 493 if (_position == _end) { |
494 _current = null; | 494 _current = null; |
495 return false; | 495 return false; |
496 } | 496 } |
497 _current = ((__x19) => DEVC$RT.cast(__x19, dynamic, E, "CastGeneral", """line 7
38, column 16 of dart:collection/queue.dart: """, __x19 is E, false))(_queue._ta
ble[_position]); | 497 _current = ((__x19) => DEVC$RT.cast(__x19, dynamic, E, "CompositeCast", """line
738, column 16 of dart:collection/queue.dart: """, __x19 is E, false))(_queue._
table[_position]); |
498 _position = (_position + 1) & (_queue._table.length - 1); | 498 _position = (_position + 1) & (_queue._table.length - 1); |
499 return true; | 499 return true; |
500 } | 500 } |
501 } | 501 } |
OLD | NEW |