Packageorg.as3collections
Interfacepublic interface IQueue extends ICollection, IIterable, org.as3coreaddendum.system.ICloneable, org.as3coreaddendum.system.IEquatable
Implementors AbstractQueue, TypedQueue, UniqueQueue

A collection designed for holding elements prior to processing. Besides basic ICollection operations, queues provide additional insertion, extraction, and inspection operations. Each of these methods exists in two forms: one throws an error if the operation fails, the other returns a special value (either null or false, depending on the operation).

Throws error Returns special value
Insert add offer
Remove dequeue poll
Examine element peek

Queues typically, but do not necessarily, order elements in a FIFO (first-in-first-out) manner. Among the exceptions are priority queues, which order elements according to a supplied comparator, or the elements' natural ordering, and LIFO queues (or stacks) which order the elements LIFO (last-in-first-out). Whatever the ordering used, the head of the queue is that element which would be removed by a call to dequeue or poll. In a FIFO queue, all new elements are inserted at the tail of the queue. Other kinds of queues may use different placement rules. Every IQueue implementation must specify its ordering properties.

The offer method inserts an element if possible, otherwise returning false. This differs from the add method, which can fail to add an element only by throwing an error. The offer method is designed for use when failure is a normal, rather than exceptional occurrence.

The dequeue and poll methods remove and return the head of the queue. Exactly which element is removed from the queue is a function of the queue's ordering policy, which differs from implementation to implementation. The dequeue and poll methods differ only in their behavior when the queue is empty: the dequeue method throws an error, while the poll method returns null.

The element and peek methods return, but do not remove, the head of the queue. The element and peek methods differ only in their behavior when the queue is empty: the element method throws an error, while the peek method returns null.

IQueue implementations generally do not allow insertion of null elements



Public Properties
 PropertyDefined By
 InheritedallEquatable : Boolean
[read-only] Indicates whether all elements in this collection implement the interface org.as3coreaddendum.system.IEquatable.
ICollection
Public Methods
 MethodDefined By
 Inherited
add(element:*):Boolean
Ensures that this collection contains the specified element (optional operation).
ICollection
 Inherited
addAll(collection:ICollection):Boolean
Adds all of the elements in the specified collection to this collection (optional operation).
ICollection
 Inherited
clear():void
Removes all of the elements from this collection (optional operation).
ICollection
 Inherited
contains(o:*):Boolean
Returns true if this collection contains the specified object.
ICollection
 Inherited
containsAll(collection:ICollection):Boolean
Returns true if this collection contains all of the elements in the specified collection.
ICollection
  
Retrieves and removes the head of this queue.
IQueue
  
Retrieves, but does not remove, the head of this queue.
IQueue
 Inherited
isEmpty():Boolean
Returns true if this collection contains no elements.
ICollection
 Inherited
Returns an iterator over a set of elements.
IIterable
  
offer(element:*):Boolean
Inserts the specified element into this queue if it is possible to do so immediately without violating restrictions.
IQueue
  
peek():*
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
IQueue
  
poll():*
Retrieves and removes the head of this queue, or returns null if this queue is empty.
IQueue
 Inherited
remove(o:*):Boolean
Removes a single instance (only one occurrence) of the specified object from this collection, if it is present (optional operation).
ICollection
 Inherited
removeAll(collection:ICollection):Boolean
Removes all elements of this collection that are also contained in the specified collection (optional operation).
ICollection
 Inherited
retainAll(collection:ICollection):Boolean
Retains only the elements in this collection that are contained in the specified collection (optional operation).
ICollection
 Inherited
size():int
Returns the number of elements in this collection.
ICollection
 Inherited
toArray():Array
Returns an array containing all of the elements in this collection.
ICollection
Method Detail
dequeue()method
public function dequeue():*

Retrieves and removes the head of this queue.

Returns
* — the head of this queue.

Throws
NoSuchElementError — if this queue is empty.
element()method 
public function element():*

Retrieves, but does not remove, the head of this queue. This method differs from peek only in that it throws an error if this queue is empty.

Returns
* — the head of this queue.

Throws
NoSuchElementError — if this queue is empty.
offer()method 
public function offer(element:*):Boolean

Inserts the specified element into this queue if it is possible to do so immediately without violating restrictions. When using a restricted queue (like TypedQueue and UniqueQueue), this method is generally preferable to add, which can fail to insert an element only by throwing an error.

Parameters

element:* — the element to add.

Returns
Booleantrue if the element was added to this queue, else false.
peek()method 
public function peek():*

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

Returns
* — the head of this queue, or null if this queue is empty.
poll()method 
public function poll():*

Retrieves and removes the head of this queue, or returns null if this queue is empty.

Returns
* — the head of this queue, or null if this queue is empty.