SimplePriorityQueue

public class
loom.utils.SimplePriorityQueue

Description

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

This implementation is based on the as3ds PriorityHeap.

API overview

Constructor

SimplePriorityQueue ( size: Number )
Initializes a priority queue with a given size

Attributes

Public attributes

front: IPrioritizable read-only

The front item or null if the heap is empty

maxSize: Number read-only

The maximum capacity

size: Number read-only

Functions

Public functions

clear (): Void
contains ( obj: Object ): Boolean
dequeue (): IPrioritizable

Dequeues and returns the front item

dump (): String

Prints all elements (for debug/demo purposes only)

enqueue ( obj: IPrioritizable ): Boolean

Enqueues a prioritized item

isEmpty (): Boolean
remove ( obj: IPrioritizable ): Boolean

Removes an item

reprioritize ( obj: IPrioritizable , newPriority: Number ): Boolean

Reprioritizes an item

Constructor

SimplePriorityQueue ( size: Number )

Initializes a priority queue with a given size. @param size The size of the priority queue.

Attributes

front: IPrioritizable

read-only

The front item or null if the heap is empty.

maxSize: Number

read-only

The maximum capacity.

size: Number

read-only

Functions

clear (): Void



contains ( obj: Object ): Boolean

Parameters

obj: Object


dequeue (): IPrioritizable

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


Returns

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

dump (): String

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



enqueue ( obj: IPrioritizable ): Boolean

Enqueues a prioritized item.

Parameters

obj: IPrioritizable The prioritized data.

Returns

Boolean False if the queue is full, otherwise true.

getFullTypeName (): String
Inherited from Object

native

Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.


Returns

String fully qualified type name of the Object.

getType (): Type
Inherited from Object

native

Gets the Type that describes the Object.


Returns

Type The Type that describes the object.

getTypeName (): String
Inherited from Object

native

Gets the type name of the Object.


Returns

String type name of the Object.

isEmpty (): Boolean



remove ( obj: IPrioritizable ): Boolean

Removes an item.

Parameters

obj: IPrioritizable The item to remove.

Returns

Boolean True if removal succeeded, otherwise false.

reprioritize ( obj: IPrioritizable , newPriority: Number ): Boolean

Reprioritizes an item.

Parameters

obj: IPrioritizable The object whose priority is changed.
newPriority: Number The new priority.

Returns

Boolean True if the repriorization succeeded, otherwise false.

toString (): String
Inherited from Object

native

Returns a String that describes the Object. This can be overriden to provide extra details when printing objects using trace().


Returns

String String that described the Object.