| 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 /** | 5 /** |
| 6 * A [Queue] is a collection that can be manipulated at both ends. One | 6 * A [Queue] is a collection that can be manipulated at both ends. One |
| 7 * can iterate over the elements of a queue through [forEach] or with | 7 * can iterate over the elements of a queue through [forEach] or with |
| 8 * an [Iterator]. | 8 * an [Iterator]. |
| 9 */ | 9 */ |
| 10 abstract class Queue<E> extends Collection<E> { | 10 abstract class Queue<E> extends Collection<E> { |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Creates a queue. | 13 * Creates a queue. |
| 14 */ | 14 */ |
| 15 factory Queue() => new DoubleLinkedQueue<E>(); | 15 factory Queue() => new DoubleLinkedQueue<E>(); |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Creates a queue with the elements of [other]. The order in | 18 * Creates a queue with the elements of [other]. The order in |
| 19 * the queue will be the order provided by the iterator of [other]. | 19 * the queue will be the order provided by the iterator of [other]. |
| 20 */ | 20 */ |
| 21 factory Queue.from(Iterable<E> other) => new DoubleLinkedQueue<E>.from(other); | 21 factory Queue.from(Iterable<E> other) => new DoubleLinkedQueue<E>.from(other); |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Removes and returns the first element of this queue. Throws an | 24 * Removes and returns the first element of this queue. Throws an |
| 25 * [EmptyQueueException] exception if this queue is empty. | 25 * [StateError] exception if this queue is empty. |
| 26 */ | 26 */ |
| 27 E removeFirst(); | 27 E removeFirst(); |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Removes and returns the last element of the queue. Throws an | 30 * Removes and returns the last element of the queue. Throws an |
| 31 * [EmptyQueueException] exception if this queue is empty. | 31 * [StateError] exception if this queue is empty. |
| 32 */ | 32 */ |
| 33 E removeLast(); | 33 E removeLast(); |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Adds [value] at the beginning of the queue. | 36 * Adds [value] at the beginning of the queue. |
| 37 */ | 37 */ |
| 38 void addFirst(E value); | 38 void addFirst(E value); |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * Adds [value] at the end of the queue. | 41 * Adds [value] at the end of the queue. |
| 42 */ | 42 */ |
| 43 void addLast(E value); | 43 void addLast(E value); |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Adds [value] at the end of the queue. | 46 * Adds [value] at the end of the queue. |
| 47 */ | 47 */ |
| 48 void add(E value); | 48 void add(E value); |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Adds all elements of [collection] at the end of the queue. The | 51 * Adds all elements of [collection] at the end of the queue. The |
| 52 * length of the queue is extended by the length of [collection]. | 52 * length of the queue is extended by the length of [collection]. |
| 53 */ | 53 */ |
| 54 void addAll(Collection<E> collection); | 54 void addAll(Collection<E> collection); |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Returns the first element of the queue. Throws an | 57 * Returns the first element of the queue. Throws an |
| 58 * [EmptyQueueException] exception if this queue is empty. | 58 * [StateError] exception if this queue is empty. |
| 59 */ | 59 */ |
| 60 E first(); | 60 E first(); |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Returns the last element of the queue. Throws an | 63 * Returns the last element of the queue. Throws an |
| 64 * [EmptyQueueException] exception if this queue is empty. | 64 * [StateError] exception if this queue is empty. |
| 65 */ | 65 */ |
| 66 E last(); | 66 E last(); |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Removes all elements in the queue. The size of the queue becomes zero. | 69 * Removes all elements in the queue. The size of the queue becomes zero. |
| 70 */ | 70 */ |
| 71 void clear(); | 71 void clear(); |
| 72 } | 72 } |
| OLD | NEW |