| Package | org.as3collections |
| Class | public class AbstractQueue |
| Inheritance | AbstractQueue AbstractArrayCollection Object |
| Implements | IQueue |
| Subclasses | LinearQueue |
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.
| Method | Defined 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 | ||
![]() | addAll(collection:ICollection):Boolean
Adds all of the elements in the specified collection to this collection (optional operation). | AbstractArrayCollection | |
![]() | clear():void
Removes all of the elements from this collection (optional operation). | AbstractArrayCollection | |
![]() | clone():*
Creates and return a shallow copy of this collection. | AbstractArrayCollection | |
![]() | contains(o:*):Boolean
Returns true if this collection contains the specified object. | AbstractArrayCollection | |
![]() | containsAll(collection:ICollection):Boolean
Returns true if this collection contains all of the elements in the specified collection. | AbstractArrayCollection | |
dequeue():*
Retrieves and removes the head of this queue. | AbstractQueue | ||
element():*
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 | ||
![]() | isEmpty():Boolean
Returns true if this collection contains no elements. | AbstractArrayCollection | |
![]() |
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 | ||
![]() | remove(o:*):Boolean
Removes a single instance (only one occurrence) of the specified object from this collection, if it is present (optional operation). | AbstractArrayCollection | |
![]() | removeAll(collection:ICollection):Boolean
Removes all of this collection's elements that are also contained in the specified collection (optional operation). | AbstractArrayCollection | |
![]() | retainAll(collection:ICollection):Boolean
Retains only the elements in this collection that are contained in the specified collection (optional operation). | AbstractArrayCollection | |
![]() | size():int
Returns the number of elements in this collection. | AbstractArrayCollection | |
![]() | toArray():Array
Returns an array containing all of the elements in this collection. | AbstractArrayCollection | |
![]() | toString():String
Returns the string representation of this instance. | AbstractArrayCollection | |
| AbstractQueue | () | Constructor |
public function AbstractQueue(source:Array = null)
Constructor, creates a new AbstractQueue object.
source:Array (default = null) — an array to fill the queue.
|
IllegalOperationError — If this class is instantiated directly, in other words, if there is not another class extending this class.
|
| 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.
|
Boolean — true if this queue changed as a result of the call.
|
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.
* — the head of this queue.
|
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.
* — the head of this queue.
|
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.
|
Boolean — true 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.
|
Boolean — true if the element was added to this queue, else false.
|
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.
* — the head of this queue, or null if this queue is empty.
|
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.
* — the head of this queue, or null if this queue is empty.
|
org.as3coreaddendum.errors:UnsupportedOperationError — if the poll operation is not supported by this queue.
|