GODPAPER | All Packages | All Classes | Index | Frames No Frames |
PriorityQueue

Package | de.polygonal.ds
Class | public class PriorityQueue
Inheritance | PriorityQueue Object
Implements | Collection

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

See also

Heap

Public Properties

| Property | Defined By
--- | --- | ---
|  | front : Prioritizable [read-only] The front item or null if the heap is empty. | PriorityQueue
|  | maxSize : int [read-only] The maximum capacity. | PriorityQueue
|  | size : int [read-only] The total number of items. | PriorityQueue

Public Methods

| Method | Defined By
--- | --- | ---
|  | PriorityQueue(size:int) Initializes a priority queue with a given size. | PriorityQueue
|  | clear():void Clears all items. | PriorityQueue
|  | contains(obj:*):Boolean Determines if the collection contains a given item. | PriorityQueue
|  | dequeue():Prioritizable Dequeues and returns the front item. | PriorityQueue
|  | dump():String Prints all elements (for debug/demo purposes only). | PriorityQueue
|  | enqueue(obj:Prioritizable):Boolean Enqueues a prioritized item. | PriorityQueue
|  | getIterator():Iterator Initializes an iterator object pointing to the first item in the collection. | PriorityQueue
|  | isEmpty():Boolean Checks if the collection is empty. | PriorityQueue
|  | remove(obj:Prioritizable):Boolean Removes an item. | PriorityQueue
|  | reprioritize(obj:Prioritizable, newPriority:int):Boolean Reprioritizes an item. | PriorityQueue
|  | toArray():Array Converts the collection into an array. | PriorityQueue
|  | toString():String Prints out a string representing the current object. | PriorityQueue

Property Detail

front | property

`front:Prioritizable` [read-only]

The front item or null if the heap is empty.

Implementation
`public function get front():Prioritizable`

maxSize | property |

`maxSize:int` [read-only]

The maximum capacity.

Implementation
`public function get maxSize():int`

size | property |

`size:int` [read-only]

The total number of items.

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

PriorityQueue | () | Constructor

`public function PriorityQueue(size:int)`

Initializes a priority queue with a given size.

Parameters

| `size:int` — The size of the priority queue.

Method Detail

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():Prioritizable`

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

Returns

| `Prioritizable` — The queue's front item or null if the heap is empty.

dump | () | method |

`public function dump():String`

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

Returns

| `String`

enqueue | () | method |

`public function enqueue(obj:Prioritizable):Boolean`

Enqueues a prioritized item.

Parameters

| `obj:Prioritizable` — The prioritized data.

Returns

| `Boolean` — False if the queue is full, otherwise true.

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.

remove | () | method |

`public function remove(obj:Prioritizable):Boolean`

Removes an item.

Parameters

| `obj:Prioritizable` — The item to remove.

Returns

| `Boolean` — True if removal succeeded, otherwise false.

reprioritize | () | method |

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

Reprioritizes an item.

Parameters

| `obj:Prioritizable` — The object whose priority is changed.
| `newPriority:int` — The new priority.

Returns

| `Boolean` — True if the repriorization succeeded, otherwise false.

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.

Thu Jan 16 2014, 01:11 PM +08:00