Files
sdk/lib/core/queue.dart
T
lrn@google.com ee569ce10a Reapply conversion of most core interfaces to abstract classes.
Previous commit was reverted due to hitting an unrelated error.

TBR=ahe@google.com

Review URL: https://codereview.chromium.org//10939030

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12551 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-19 10:48:14 +00:00

73 lines
1.8 KiB
Dart

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/**
* A [Queue] is a collection that can be manipulated at both ends. One
* can iterate over the elements of a queue through [forEach] or with
* an [Iterator].
*/
abstract class Queue<E> extends Collection<E> {
/**
* Creates a queue.
*/
factory Queue() => new DoubleLinkedQueue<E>();
/**
* Creates a queue with the elements of [other]. The order in
* the queue will be the order provided by the iterator of [other].
*/
factory Queue.from(Iterable<E> other) => new DoubleLinkedQueue<E>.from(other);
/**
* Removes and returns the first element of this queue. Throws an
* [EmptyQueueException] exception if this queue is empty.
*/
E removeFirst();
/**
* Removes and returns the last element of the queue. Throws an
* [EmptyQueueException] exception if this queue is empty.
*/
E removeLast();
/**
* Adds [value] at the beginning of the queue.
*/
void addFirst(E value);
/**
* Adds [value] at the end of the queue.
*/
void addLast(E value);
/**
* Adds [value] at the end of the queue.
*/
void add(E value);
/**
* Adds all elements of [collection] at the end of the queue. The
* length of the queue is extended by the length of [collection].
*/
void addAll(Collection<E> collection);
/**
* Returns the first element of the queue. Throws an
* [EmptyQueueException] exception if this queue is empty.
*/
E first();
/**
* Returns the last element of the queue. Throws an
* [EmptyQueueException] exception if this queue is empty.
*/
E last();
/**
* Removes all elements in the queue. The size of the queue becomes zero.
*/
void clear();
}