| Package | ch.capi.data.tree |
| Class | public class ArrayHeap |
| 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 into 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.
Implementation 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.
Implementation 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.
Parameterselement:* — 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 into the ArrayHeap.
element:* — The element.
|
Boolean — true if the element is contained into 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 into the
ArrayHeap, then -1 is returned.
element:* — 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 into
the structure.
|
| remove | () | method |
public function remove():*Removes an element from the data structure.
Returns* — The element removed.
|