| Package | ch.capi.data.tree |
| Class | public class ArrayHeap |
| Inheritance | ArrayHeap Object |
| Implements | IHeap |
IHeap.
| Property | Defined By | ||
|---|---|---|---|
| nextElement : * [read-only]
Defines the next element that will be removed
from the data structure. | ArrayHeap | ||
| sortFunction : Function [read-only]
Defines the sort function that will be used to sort
the items. | ArrayHeap | ||
| Method | Defined By | ||
|---|---|---|---|
ArrayHeap(sortFunction:Function)
Creates a new ArrayHeap object. | ArrayHeap | ||
add(element:*):void
Add an element to the data structure. | ArrayHeap | ||
clear():void
Removes all the elements from the data structure. | ArrayHeap | ||
contains(element:*):Boolean
Retrieves if the specified element is contained in the ArrayHeap. | ArrayHeap | ||
getDepth():uint
Retrieves the depth of the Heap. | ArrayHeap | ||
getElementDepth(element:*):int
Retrieves the depth of an alement. | ArrayHeap | ||
isEmpty():Boolean
Get if the structure is empty or not. | ArrayHeap | ||
remove():*
Removes an element from the data structure. | ArrayHeap | ||
| nextElement | property |
nextElement:* [read-only] Defines the next element that will be removed from the data structure.
public function get nextElement():*| sortFunction | property |
sortFunction:Function [read-only] Defines the sort function that will be used to sort the items. The sort function must take two parameters and return an int value comparing it.
public function get sortFunction():Function
var f:Function = function(a:int, b:int):int
{
return b-a;
}
var h:ArrayHeap = new ArrayHeap(f);
h.add(5);
h.add(4);
h.add(6);
h.add(2);
while (!h.isEmpty()) trace(h.remove);
| ArrayHeap | () | Constructor |
public function ArrayHeap(sortFunction:Function)
Creates a new ArrayHeap object.
sortFunction:Function — The sort function.
|
| add | () | method |
public function add(element:*):voidAdd an element to the data structure.
Parameters
element:* — The element to add.
|
| clear | () | method |
public function clear():voidRemoves all the elements from the data structure.
| contains | () | method |
public function contains(element:*):Boolean
Retrieves if the specified element is contained in the ArrayHeap.
Parameters
element:* — The element.
|
Boolean — true if the element is contained in the ArrayHeap.
|
| getDepth | () | method |
public function getDepth():uint
Retrieves the depth of the Heap.
uint — The depth.
|
| getElementDepth | () | method |
public function getElementDepth(element:*):int
Retrieves the depth of an alement. If the specified element is not in the
ArrayHeap, then -1 is returned.
Parameters
element:* — The element.
|
int — The element depth or -1.
|
| isEmpty | () | method |
public function isEmpty():BooleanGet if the structure is empty or not.
ReturnsBoolean — true if there is no element in
the structure.
|
| remove | () | method |
public function remove():*Removes an element from the data structure.
Returns* — The element removed.
|