Interface common to heap data structures. Heaps are tree-like data structures that allow storing elements in a specific way. Each node corresponds to an element and has one parent node (except for the root) and at most two children nodes. Every element contains a key, and those keys indicat
| 19 | * @author Nicolas Renard |
| 20 | */ |
| 21 | public interface Heap { |
| 22 | /** |
| 23 | * @return the top element in the heap, the one with lowest key for min-heap |
| 24 | * or with the highest key for max-heap |
| 25 | * @throws EmptyHeapException if heap is empty |
| 26 | */ |
| 27 | HeapElement getElement() throws EmptyHeapException; |
| 28 | |
| 29 | /** |
| 30 | * Inserts an element in the heap. Adds it to then end and toggle it until |
| 31 | * it finds its right position. |
| 32 | * |
| 33 | * @param element an instance of the HeapElement class. |
| 34 | */ |
| 35 | void insertElement(HeapElement element); |
| 36 | |
| 37 | /** |
| 38 | * Delete an element in the heap. |
| 39 | * |
| 40 | * @param elementIndex int containing the position in the heap of the |
| 41 | * element to be deleted. |
| 42 | */ |
| 43 | void deleteElement(int elementIndex) throws EmptyHeapException; |
| 44 | } |
no outgoing calls
no test coverage detected