Packagede.polygonal.ds
Classpublic class ArrayedQueue
InheritanceArrayedQueue Inheritance Object
Implements Collection

A queue based on an array (circular queue). This is called a FIFO structure (First In, First Out).

See also

LinkedQueue


Public Properties
 PropertyDefined By
  maxSize : int
[read-only] The queue's maximum capacity.
ArrayedQueue
  size : int
[read-only] The total number of items.
ArrayedQueue
Public Methods
 MethodDefined By
  
ArrayedQueue(size:int)
Initializes a queue object to match the given size.
ArrayedQueue
  
back():*
Indicates the most recently added item.
ArrayedQueue
  
clear():void
Clears all items.
ArrayedQueue
  
contains(obj:*):Boolean
Determines if the collection contains a given item.
ArrayedQueue
  
Dequeues and returns the front item.
ArrayedQueue
  
dispose():void
Deletes the last dequeued item to free it for the garbage collector.
ArrayedQueue
  
dump():String
Prints out all elements (for debug/demo purposes).
ArrayedQueue
  
enqueue(obj:*):Boolean
Enqueues some data.
ArrayedQueue
  
getAt(i:int):*
Reads an item relative to the front index.
ArrayedQueue
  
Initializes an iterator object pointing to the first item in the collection.
ArrayedQueue
  
isEmpty():Boolean
Checks if the collection is empty.
ArrayedQueue
  
peek():*
Indicates the front item.
ArrayedQueue
  
setAt(i:int, obj:*):void
Writes an item relative to the front index.
ArrayedQueue
  
toArray():Array
Converts the collection into an array.
ArrayedQueue
  
toString():String
Prints out a string representing the current object.
ArrayedQueue
Property Detail
maxSizeproperty
maxSize:int  [read-only]

The queue's maximum capacity.


Implementation
    public function get maxSize():int
sizeproperty 
size:int  [read-only]

The total number of items.


Implementation
    public function get size():int
Constructor Detail
ArrayedQueue()Constructor
public function ArrayedQueue(size:int)

Initializes a queue object to match the given size. The size must be a power of two - if not the size is automatically rounded to the next largest power of 2. The initial value of all items is null.

Parameters
size:int — The queue's size.
Method Detail
back()method
public function back():*

Indicates the most recently added item.

Returns
* — The last item in the queue or null if the queue is empty.
clear()method 
public function clear():void

Clears all items.

contains()method 
public function contains(obj:*):Boolean

Determines if the collection contains a given item.

Parameters

obj:* — The item to search for.

Returns
Boolean — True if the item exists, otherwise false.
dequeue()method 
public function dequeue():*

Dequeues and returns the front item.

Returns
* — The front item or null if the queue is empty.
dispose()method 
public function dispose():void

Deletes the last dequeued item to free it for the garbage collector. Use only directly after you have invoked dequeue().


Example
The following code clears the dequeued item:
         myQueue.dequeue();
         myQueue.dispose();
         
dump()method 
public function dump():String

Prints out all elements (for debug/demo purposes).

Returns
String — A human-readable representation of the structure.
enqueue()method 
public function enqueue(obj:*):Boolean

Enqueues some data.

Parameters

obj:* — The data to enqueue.

Returns
Boolean — True if the item fits into the queue, otherwise false.
getAt()method 
public function getAt(i:int):*

Reads an item relative to the front index.

Parameters

i:int — The index of the item.

Returns
* — The item at the given index.
getIterator()method 
public function getIterator():Iterator

Initializes an iterator object pointing to the first item in the collection.

Returns
Iterator — An iterator object.
isEmpty()method 
public function isEmpty():Boolean

Checks if the collection is empty.

Returns
Boolean — True if empty, otherwise false.
peek()method 
public function peek():*

Indicates the front item.

Returns
* — The front item or null if the queue is empty.
setAt()method 
public function setAt(i:int, obj:*):void

Writes an item relative to the front index.

Parameters

i:int — The index of the item.
 
obj:* — The data.

toArray()method 
public function toArray():Array

Converts the collection into an array.

Returns
Array — An array.
toString()method 
public function toString():String

Prints out a string representing the current object.

Returns
String — A string representing the current object.