OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of "collection.dart"; | 5 part of "collection.dart"; |
6 | 6 |
7 /** | 7 /** |
8 * A [Queue] is a collection that can be manipulated at both ends. One | 8 * A [Queue] is a collection that can be manipulated at both ends. One |
9 * can iterate over the elements of a queue through [forEach] or with | 9 * can iterate over the elements of a queue through [forEach] or with |
10 * an [Iterator]. | 10 * an [Iterator]. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 if (_nextLink != null) _nextLink._previousLink = _previousLink; | 110 if (_nextLink != null) _nextLink._previousLink = _previousLink; |
111 _nextLink = null; | 111 _nextLink = null; |
112 _previousLink = null; | 112 _previousLink = null; |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 /** | 116 /** |
117 * An entry in a doubly linked list. It contains a pointer to the next | 117 * An entry in a doubly linked list. It contains a pointer to the next |
118 * entry, the previous entry, and the boxed element. | 118 * entry, the previous entry, and the boxed element. |
119 */ | 119 */ |
| 120 @deprecated |
120 class DoubleLinkedQueueEntry<E> extends _DoubleLink<DoubleLinkedQueueEntry<E>> { | 121 class DoubleLinkedQueueEntry<E> extends _DoubleLink<DoubleLinkedQueueEntry<E>> { |
121 /// The element in the queue. | 122 /// The element in the queue. |
122 E element; | 123 E element; |
123 | 124 |
124 DoubleLinkedQueueEntry(this.element); | 125 DoubleLinkedQueueEntry(this.element); |
125 | 126 |
126 /// Appends the given [e] as entry just after this entry. | 127 /// Appends the given [e] as entry just after this entry. |
127 void append(E e) { | 128 void append(E e) { |
128 new DoubleLinkedQueueEntry<E>(e)._link(this, _nextLink); | 129 new DoubleLinkedQueueEntry<E>(e)._link(this, _nextLink); |
129 } | 130 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 246 |
246 /** Hit by, e.g., [DoubleLinkedQueue.first] if the queue is empty. */ | 247 /** Hit by, e.g., [DoubleLinkedQueue.first] if the queue is empty. */ |
247 E get _element { | 248 E get _element { |
248 throw IterableElementError.noElement(); | 249 throw IterableElementError.noElement(); |
249 } | 250 } |
250 } | 251 } |
251 | 252 |
252 /** | 253 /** |
253 * A [Queue] implementation based on a double-linked list. | 254 * A [Queue] implementation based on a double-linked list. |
254 * | 255 * |
| 256 * Deprecated. Use [ListQueue] or `DoubleLinkedQueue` from package |
| 257 * `collection`, instead. [https://pub.dartlang.org/packages/collection] |
| 258 * |
255 * Allows constant time add, remove-at-ends and peek operations. | 259 * Allows constant time add, remove-at-ends and peek operations. |
256 */ | 260 */ |
| 261 @deprecated |
257 class DoubleLinkedQueue<E> extends Iterable<E> implements Queue<E> { | 262 class DoubleLinkedQueue<E> extends Iterable<E> implements Queue<E> { |
258 _DoubleLinkedQueueSentinel<E> _sentinel; | 263 _DoubleLinkedQueueSentinel<E> _sentinel; |
259 int _elementCount = 0; | 264 int _elementCount = 0; |
260 | 265 |
261 DoubleLinkedQueue() { | 266 DoubleLinkedQueue() { |
262 _sentinel = new _DoubleLinkedQueueSentinel<E>(this); | 267 _sentinel = new _DoubleLinkedQueueSentinel<E>(this); |
263 } | 268 } |
264 | 269 |
265 /** | 270 /** |
266 * Creates a double-linked queue containing all [elements]. | 271 * Creates a double-linked queue containing all [elements]. |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 _queue._checkModification(_modificationCount); | 877 _queue._checkModification(_modificationCount); |
873 if (_position == _end) { | 878 if (_position == _end) { |
874 _current = null; | 879 _current = null; |
875 return false; | 880 return false; |
876 } | 881 } |
877 _current = _queue._table[_position]; | 882 _current = _queue._table[_position]; |
878 _position = (_position + 1) & (_queue._table.length - 1); | 883 _position = (_position + 1) & (_queue._table.length - 1); |
879 return true; | 884 return true; |
880 } | 885 } |
881 } | 886 } |
OLD | NEW |