| Package | de.polygonal.ds |
| Class | public class Heap |
| Inheritance | Heap Object |
| Implements | Collection |
See also
| Property | Defined By | ||
|---|---|---|---|
| front : * [read-only]
The heap's front item. | Heap | ||
| _heap : Array | Heap | ||
| maxSize : int [read-only]
The heap's maximum capacity. | Heap | ||
| size : int [read-only]
The total number of items. | Heap | ||
| Method | Defined By | ||
|---|---|---|---|
Heap(size:int, compare:Function = null)
Initializes a new heap. | Heap | ||
clear():void
Clears all items. | Heap | ||
contains(obj:*):Boolean
Checks if a given item exists. | Heap | ||
dequeue():*
Dequeues and returns the front item. | Heap | ||
dump():String
Prints out all elements (for debug/demo purposes). | Heap | ||
enqueue(obj:*):Boolean
Enqueues some data. | Heap | ||
Initializes an iterator object pointing to the first item in the
collection. | Heap | ||
isEmpty():Boolean
Checks if the collection is empty. | Heap | ||
toArray():Array
Converts the collection into an array. | Heap | ||
toString():String
Prints out a string representing the current object. | Heap | ||
| _heap | property |
public var _heap:Array| front | property |
front:* [read-only] The heap's front item.
public function get front():*| maxSize | property |
maxSize:int [read-only] The heap's maximum capacity.
public function get maxSize():int| size | property |
size:int [read-only] The total number of items.
public function get size():int| Heap | () | Constructor |
public function Heap(size:int, compare:Function = null)Initializes a new heap.
Parameterssize:int — The heap's maximum capacity.
| |
compare:Function (default = null) — A comparison function for sorting the heap's data.
If no function is passed, the heap uses a function for
comparing numbers.
|
| clear | () | method |
public function clear():voidClears all items.
| contains | () | method |
public function contains(obj:*):BooleanChecks if a given item exists.
Parameters
obj:* |
Boolean — True if the item is found, otherwise false.
|
| dequeue | () | method |
public function dequeue():*Dequeues and returns the front item.
Returns* — The heap's front item or null if it is empty.
|
| dump | () | method |
public function dump():StringPrints out all elements (for debug/demo purposes).
ReturnsString — A human-readable representation of the structure.
|
| enqueue | () | method |
public function enqueue(obj:*):BooleanEnqueues some data.
Parameters
obj:* — The data to enqueue.
|
Boolean — False if the queue is full, otherwise true.
|
| getIterator | () | method |
public function getIterator():IteratorInitializes an iterator object pointing to the first item in the collection.
ReturnsIterator — An iterator object.
|
| isEmpty | () | method |
public function isEmpty():BooleanChecks if the collection is empty.
ReturnsBoolean — True if empty, otherwise false.
|
| toArray | () | method |
public function toArray():ArrayConverts the collection into an array.
ReturnsArray — An array.
|
| toString | () | method |
public function toString():StringPrints out a string representing the current object.
ReturnsString — A string representing the current object.
|