public class Heap extends Object implements Serializable
| Constructor and Description |
|---|
Heap()
Creates an instance of a Heap.
|
Heap(HeapNodeComparator comparator)
Creates an instance of a Heap, with a specified HeapNodeComparator.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the heap, removing all nodes in the heap.
|
HeapNode |
contains(Object object,
Comparator heapnodeobjectcomparator)
Determines if the given object is encapsulated by one of the nodes
in the heap.
|
void |
insert(HeapNode node)
Add a new item into the heap
|
boolean |
isEmpty()
Checks if the heap is empty
|
HeapNode |
remove()
Remove the item with the highest priority from the heap.
|
void |
setPriority(HeapNode node,
double priority)
Sets the priority of a specific node in the heap, thereby also forcing
to fixup the heap to satisfy the heap condition.
|
String |
toString()
Returns a String representation of the Heap.
|
public Heap()
public Heap(HeapNodeComparator comparator)
comapartor - The HeapNodeComparator object to be used in comparing
the priorities of the nodes of the heap.public void insert(HeapNode node)
public HeapNode remove()
public void setPriority(HeapNode node, double priority)
node - The HeapNode object whose priority is to be changedpriority - The new priority that will be assigned to the heapnode.public void clear()
public boolean isEmpty()
public HeapNode contains(Object object, Comparator heapnodeobjectcomparator)
Copyright © 2019 JULIE Lab, Germany. All rights reserved.