| Package | system.data.queues |
| Class | public class PriorityQueue |
| Inheritance | PriorityQueue LinearQueue ArrayCollection Object |
| Implements | Sortable |
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) ;
| Property | Defined 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 | ||
| Method | Defined By | ||
|---|---|---|---|
PriorityQueue(init:* = null, comp:Comparator = null, options:uint = 0)
Creates a new PriorityQueue instance. | PriorityQueue | ||
![]() | add(o:*):Boolean
Inserts an element in the collection. | ArrayCollection | |
![]() | 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 | |
![]() | clear():void
Removes all elements in the collection. | ArrayCollection | |
clone():* [override]
Returns a shallow copy of this object. | PriorityQueue | ||
![]() | contains(o:*):Boolean
Returns true if this collection contains the specified element. | ArrayCollection | |
![]() | containsAll(c:Collection):Boolean
Returns true if this collection contains all of the elements of the specified collection. | ArrayCollection | |
![]() | dequeue():Boolean
Retrieves and removes the head of this queue. | LinearQueue | |
![]() | element():*
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 | ||
![]() | equals(o:*):Boolean
Compares the specified object with this object for equality. | ArrayCollection | |
![]() | get(key:*):*
Returns the element from this collection at the passed key index. | ArrayCollection | |
![]() | indexOf(o:*, fromIndex:uint = 0):int
Returns the index of an element in the collection. | ArrayCollection | |
![]() | isEmpty():Boolean
Returns true if this collection contains no elements. | ArrayCollection | |
![]() |
Returns the iterator reference of the object. | ArrayCollection | |
![]() | peek():*
Retrieves, but does not remove, the head of this queue, returning null if this queue is empty. | LinearQueue | |
![]() | poll():*
Retrieves and removes the head of this queue. | LinearQueue | |
![]() | remove(o:*):*
Removes a single instance of the specified element from this collection, if it is present (optional operation). | ArrayCollection | |
![]() | removeAll(c:Collection):Boolean
Removes from this Collection all the elements that are contained in the specified Collection (optional operation). | ArrayCollection | |
![]() | retainAll(c:Collection):Boolean
Retains only the elements in this Collection that are contained in the specified Collection (optional operation). | ArrayCollection | |
![]() | 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 | ||
![]() | toArray():Array
Returns an array containing all of the elements in this collection. | ArrayCollection | |
![]() | toSource(indent:int = 0):String
Returns the source code string representation of the object. | ArrayCollection | |
![]() | toString():String
Returns the string representation of this instance. | ArrayCollection | |
| Constant | Defined By | ||
|---|---|---|---|
| NONE : uint = 0 [static]
The default options value. | PriorityQueue | ||
| comparator | property |
comparator:Comparator
Determinates the Comparator strategy used to sort the instance.
public function get comparator():Comparator public function set comparator(value:Comparator):void| options | property |
options:uintIndicates the options to sort the elements in the list.
public function get options():uint public function set options(value:uint):void| PriorityQueue | () | Constructor |
public function PriorityQueue(init:* = null, comp:Comparator = null, options:uint = 0)Creates a new PriorityQueue instance.
Parametersinit:* (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.
|
| 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:*):BooleanInserts the specified element into this queue, if possible.
Parameters
o:* |
Boolean |
| sort | () | method |
public function sort(... arguments):voidSorts the queue with the internal Comparator or with the Array.sort method if the method a.
Parameters
... arguments |
| NONE | Constant |
public static const NONE:uint = 0The default options value.