Packageorg.as3collections
Classpublic class AbstractQueue
InheritanceAbstractQueue Inheritance AbstractArrayCollection Inheritance Object
Implements IQueue
Subclasses LinearQueue

This class provides skeletal implementations of some IQueue operations. The implementations in this class are appropriate when the base implementation does not allow null elements. Methods add, dequeue, and element are based on offer, poll, and peek, respectively but throw errors instead of indicating failure via false or null returns.

An IQueue implementation that extends this class must minimally define a method offer which does not permit insertion of null elements, along with methods peek, poll, ICollection.iterator supporting IIterator.remove and clone. Typically, additional methods will be overridden as well. If these requirements cannot be met, consider instead subclassing AbstractArrayCollection.



Public Properties
 PropertyDefined By
 InheritedallEquatable : Boolean
[read-only] Indicates whether all elements in this collection implement the interface org.as3coreaddendum.system.IEquatable.
AbstractArrayCollection
Public Methods
 MethodDefined By
  
AbstractQueue(source:Array = null)
Constructor, creates a new AbstractQueue object.
AbstractQueue
  
add(element:*):Boolean
[override] Inserts the specified element into this queue if it is possible to do so immediately without violating restrictions.
AbstractQueue
 Inherited
addAll(collection:ICollection):Boolean
Adds all of the elements in the specified collection to this collection (optional operation).
AbstractArrayCollection
 Inherited
clear():void
Removes all of the elements from this collection (optional operation).
AbstractArrayCollection
 Inherited
clone():*
Creates and return a shallow copy of this collection.
AbstractArrayCollection
 Inherited
contains(o:*):Boolean
Returns true if this collection contains the specified object.
AbstractArrayCollection
 Inherited
containsAll(collection:ICollection):Boolean
Returns true if this collection contains all of the elements in the specified collection.
AbstractArrayCollection
  
Retrieves and removes the head of this queue.
AbstractQueue
  
Retrieves, but does not remove, the head of this queue.
AbstractQueue
  
equals(other:*):Boolean
[override] This method uses CollectionUtil.equalConsideringOrder method to perform equality, sending this list and other argument.
AbstractQueue
 Inherited
isEmpty():Boolean
Returns true if this collection contains no elements.
AbstractArrayCollection
 Inherited
Returns an iterator over a set of elements.
AbstractArrayCollection
  
offer(element:*):Boolean
Inserts the specified element into this queue if it is possible to do so immediately without violating restrictions.
AbstractQueue
  
peek():*
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
AbstractQueue
  
poll():*
Retrieves and removes the head of this queue, or returns null if this queue is empty.
AbstractQueue
 Inherited
remove(o:*):Boolean
Removes a single instance (only one occurrence) of the specified object from this collection, if it is present (optional operation).
AbstractArrayCollection
 Inherited
removeAll(collection:ICollection):Boolean
Removes all of this collection's elements that are also contained in the specified collection (optional operation).
AbstractArrayCollection
 Inherited
retainAll(collection:ICollection):Boolean
Retains only the elements in this collection that are contained in the specified collection (optional operation).
AbstractArrayCollection
 Inherited
size():int
Returns the number of elements in this collection.
AbstractArrayCollection
 Inherited
toArray():Array
Returns an array containing all of the elements in this collection.
AbstractArrayCollection
 Inherited
toString():String
Returns the string representation of this instance.
AbstractArrayCollection
Constructor Detail
AbstractQueue()Constructor
public function AbstractQueue(source:Array = null)

Constructor, creates a new AbstractQueue object.

Parameters
source:Array (default = null) — an array to fill the queue.

Throws
IllegalOperationError — If this class is instantiated directly, in other words, if there is not another class extending this class.
Method Detail
add()method
override public function add(element:*):Boolean

Inserts the specified element into this queue if it is possible to do so immediately without violating restrictions. This method differs from offer only in that it throws an error if the element cannot be inserted.

This implementation returns the result of offer unless the element cannot be inserted.

Parameters

element:* — the element to be added.

Returns
Booleantrue if this queue changed as a result of the call.

Throws
ArgumentError — if the specified element is null.
 
org.as3coreaddendum.errors:ClassCastError — if the class of the specified element prevents it from being added to this queue.
 
flash.errors:IllegalOperationError — if the specified element cannot be inserted.
dequeue()method 
public function dequeue():*

Retrieves and removes the head of this queue. This method differs from poll only in that it throws an error if this queue is empty.

This implementation returns the result of poll unless the queue is empty.

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.

This implementation returns the result of peek unless the queue is empty.

Returns
* — the head of this queue.

Throws
NoSuchElementError — if this queue is empty.
equals()method 
override public function equals(other:*):Boolean

This method uses CollectionUtil.equalConsideringOrder method to perform equality, sending this list and other argument.

Parameters

other:* — the object to be compared for equality.

Returns
Booleantrue if the arbitrary evaluation considers the objects equal.

See also

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.

This implementation always throws an UnsupportedOperationError.

Parameters

element:* — the element to add.

Returns
Booleantrue if the element was added to this queue, else false.

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the offer operation is not supported by this queue.
peek()method 
public function peek():*

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

This implementation always throws an UnsupportedOperationError.

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

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the peek operation is not supported by this queue.
poll()method 
public function poll():*

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

This implementation always throws an UnsupportedOperationError.

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

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the poll operation is not supported by this queue.