PriorityQueue

PriorityQueue

A priority queue to manage prioritized data.  The implementation is based on the heap structure.

See Also

Heap

Summary
PriorityQueueA priority queue to manage prioritized data.
Functions and Properties
PriorityQueueInitializes a priority queue with a given size.
frontThe front item or null if the heap is empty.
maxSizeThe maximum capacity.
enqueueEnqueues a prioritized item.
dequeueDequeues and returns the front item.
reprioritizeReprioritizes an item.
removeRemoves an item.
contains@inheritDoc
clear@inheritDoc
getIterator@inheritDoc
size@inheritDoc
isEmpty@inheritDoc
toArray@inheritDoc
toStringPrints out a string representing the current object.
dumpPrints all elements (for debug/demo purposes only).

Functions and Properties

PriorityQueue

public function PriorityQueue(size: int)

Initializes a priority queue with a given size.

Parameters

sizeThe size of the priority queue. 

front

public function get front():Prioritizable

The front item or null if the heap is empty.

maxSize

public function get maxSize():int

The maximum capacity.

enqueue

public function enqueue(obj: Prioritizable):Boolean

Enqueues a prioritized item.

Parameters

objThe prioritized data.

Returns

False if the queue is full, otherwise true. 

dequeue

public function dequeue():Prioritizable

Dequeues and returns the front item.  This is always the item with the highest priority.

Returns

The queue’s front item or null if the heap is empty. 

reprioritize

public function reprioritize(obj: Prioritizable,
newPriority: int):Boolean

Reprioritizes an item.

Parameters

objThe object whose priority is changed.
newPriorityThe new priority.

Returns

True if the repriorization succeeded, otherwise false. 

remove

public function remove(obj: Prioritizable):Boolean

Removes an item.

Parameters

objThe item to remove.

Returns

True if removal succeeded, otherwise false. 

contains

public function contains(obj: *):Boolean

@inheritDoc

clear

public function clear():void

@inheritDoc

getIterator

public function getIterator():Iterator

@inheritDoc

size

public function get size():int

@inheritDoc

isEmpty

public function isEmpty():Boolean

@inheritDoc

toArray

public function toArray():Array

@inheritDoc

toString

public function toString():String

Prints out a string representing the current object.

Returns

A string representing the current object. 

dump

public function dump():String

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

A ‘java-style’ collection interface.
public function PriorityQueue(size: int)
Initializes a priority queue with a given size.
public function get front():Prioritizable
The front item or null if the heap is empty.
public function get maxSize():int
The maximum capacity.
public function enqueue(obj: Prioritizable):Boolean
Enqueues a prioritized item.
public function dequeue():Prioritizable
Dequeues and returns the front item.
public function reprioritize(obj: Prioritizable,
newPriority: int):Boolean
Reprioritizes an item.
public function remove(obj: Prioritizable):Boolean
Removes an item.
public function contains(obj: *):Boolean
@inheritDoc
public function clear():void
@inheritDoc
public function getIterator():Iterator
@inheritDoc
public function get size():int
@inheritDoc
public function isEmpty():Boolean
@inheritDoc
public function toArray():Array
@inheritDoc
public function toString():String
Prints out a string representing the current object.
public function dump():String
Prints all elements (for debug/demo purposes only).
A heap is a special kind of binary tree in which every node is greater than all of its children.
Close