Heap |
A heap is a special kind of binary tree in which every node is greater than all of its children. The implementation is based on an arrayed binary tree. It can be used as an efficient priority queue.
Heap | A heap is a special kind of binary tree in which every node is greater than all of its children. |
Functions and Properties | |
Heap | Initializes a new heap. |
front | The heap’s front item. |
maxSize | The heap’s maximum capacity. |
enqueue | Enqueues some data. |
dequeue | Dequeues and returns the front item. |
contains | Checks if a given item exists. |
clear | @inheritDoc |
getIterator | @inheritDoc |
size | @inheritDoc |
isEmpty | @inheritDoc |
toArray | @inheritDoc |
toString | Prints out a string representing the current object. |
dump | Prints out all elements (for debug/demo purposes). |
Initializes a new heap.
public function Heap( size: int, compare: Function = null )
The heap’s front item.
public function get front():*
The heap’s maximum capacity.
public function get maxSize():int
Enqueues some data.
public function enqueue( obj: * ):Boolean
Dequeues and returns the front item.
public function dequeue():*
Checks if a given item exists.
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
Prints out a string representing the current object.
public function toString():String
Prints out all elements (for debug/demo purposes).
public function dump():String