Packagesystem.data.queues
Classpublic class PriorityQueue
InheritancePriorityQueue Inheritance LinearQueue Inheritance ArrayCollection Inheritance Object
Implements Sortable

This queue orders elements according to an order specified at construction time, which is specified either according to their natural order or according to a IComparator object.

Example :

     import system.data.queues.PriorityQueue ;
     import system.comparators.AlphaComparator ;
     import system.comparators.NumberComparator ;
     
     var init:Array = [5, 4, 3, 2, 1] ;
     var q:PriorityQueue = new PriorityQueue( init , new NumberComparator() , Array.NUMERIC  )  ;
     
     trace ("queue size : " + q.size()) ;
     trace("queue " + q) ;
     
     q.options = Array.NUMERIC + Array.DESCENDING ;
     trace("queue " + q) ;
     
     q.clear() ;
     
     q.comparator = new AlphaComparator() ;
     q.options    = Array.CASEINSENSITIVE | Array.DESCENDING ;
     
     trace ("enqueue item4 : " + q.enqueue ("item4")) ;
     trace ("enqueue item2 : " + q.enqueue ("item2")) ;
     trace ("enqueue item3 : " + q.enqueue ("item3")) ;
     trace ("enqueue item1 : " + q.enqueue ("item1")) ;
     
     trace("queue " + q) ;
     
     q.options = Array.CASEINSENSITIVE ;
     trace("queue " + q) ;
     



Public Properties
 PropertyDefined By
  comparator : Comparator
Determinates the Comparator strategy used to sort the instance.
PriorityQueue
  options : uint
Indicates the options to sort the elements in the list.
PriorityQueue
Public Methods
 MethodDefined By
  
PriorityQueue(init:* = null, comp:Comparator = null, options:uint = 0)
Creates a new PriorityQueue instance.
PriorityQueue
 Inherited
add(o:*):Boolean
Inserts an element in the collection.
ArrayCollection
 Inherited
addAll(c:Collection):Boolean
Appends all of the elements in the specified collection to the end of this Collection, in the order that they are returned by the specified collection's iterator (optional operation).
ArrayCollection
 Inherited
clear():void
Removes all elements in the collection.
ArrayCollection
  
clone():*
[override] Returns a shallow copy of this object.
PriorityQueue
 Inherited
contains(o:*):Boolean
Returns true if this collection contains the specified element.
ArrayCollection
 Inherited
Returns true if this collection contains all of the elements of the specified collection.
ArrayCollection
 Inherited
dequeue():Boolean
Retrieves and removes the head of this queue.
LinearQueue
 Inherited
Retrieves, but does not remove, the head of this queue.
LinearQueue
  
enqueue(o:*):Boolean
[override] Inserts the specified element into this queue, if possible.
PriorityQueue
 Inherited
equals(o:*):Boolean
Compares the specified object with this object for equality.
ArrayCollection
 Inherited
get(key:*):*
Returns the element from this collection at the passed key index.
ArrayCollection
 Inherited
indexOf(o:*, fromIndex:uint = 0):int
Returns the index of an element in the collection.
ArrayCollection
 Inherited
isEmpty():Boolean
Returns true if this collection contains no elements.
ArrayCollection
 Inherited
Returns the iterator reference of the object.
ArrayCollection
 Inherited
peek():*
Retrieves, but does not remove, the head of this queue, returning null if this queue is empty.
LinearQueue
 Inherited
poll():*
Retrieves and removes the head of this queue.
LinearQueue
 Inherited
remove(o:*):*
Removes a single instance of the specified element from this collection, if it is present (optional operation).
ArrayCollection
 Inherited
Removes from this Collection all the elements that are contained in the specified Collection (optional operation).
ArrayCollection
 Inherited
Retains only the elements in this Collection that are contained in the specified Collection (optional operation).
ArrayCollection
 Inherited
size():uint
Returns the number of elements in this collection.
ArrayCollection
  
sort(... arguments):void
Sorts the queue with the internal Comparator or with the Array.sort method if the method a.
PriorityQueue
 Inherited
toArray():Array
Returns an array containing all of the elements in this collection.
ArrayCollection
 Inherited
toSource(indent:int = 0):String
Returns the source code string representation of the object.
ArrayCollection
 Inherited
toString():String
Returns the string representation of this instance.
ArrayCollection
Public Constants
 ConstantDefined By
  NONE : uint = 0
[static] The default options value.
PriorityQueue
Property Detail
comparatorproperty
comparator:Comparator

Determinates the Comparator strategy used to sort the instance.


Implementation
    public function get comparator():Comparator
    public function set comparator(value:Comparator):void
optionsproperty 
options:uint

Indicates the options to sort the elements in the list.


Implementation
    public function get options():uint
    public function set options(value:uint):void
Constructor Detail
PriorityQueue()Constructor
public function PriorityQueue(init:* = null, comp:Comparator = null, options:uint = 0)

Creates a new PriorityQueue instance.

Parameters
init:* (default = null) — An optional Array or Collection or Iterable object to fill the collection.
 
comp:Comparator (default = null) — An optional Comparator object used in the PriorityQueue to defined the sort model when enqueue or modify the queue.
 
options:uint (default = 0) — The optional "options" value use to sort the priority queue.
Method Detail
clone()method
override public function clone():*

Returns a shallow copy of this object.

Returns
* — a shallow copy of this object.
enqueue()method 
override public function enqueue(o:*):Boolean

Inserts the specified element into this queue, if possible.

Parameters

o:*

Returns
Boolean
sort()method 
public function sort(... arguments):void

Sorts the queue with the internal Comparator or with the Array.sort method if the method a.

Parameters

... arguments

Constant Detail
NONEConstant
public static const NONE:uint = 0

The default options value.