mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-25 13:34:54 +08:00
@ -1,4 +1,4 @@
|
||||
package heaps;
|
||||
package Heaps;
|
||||
|
||||
/**
|
||||
* Interface common to heap data structures.<br>
|
||||
@ -10,32 +10,31 @@ package heaps;
|
||||
* max-heap).</p>
|
||||
* <p>All heap-related operations (inserting or deleting an element, extracting the min or max) are performed in
|
||||
* O(log n) time.</p>
|
||||
*
|
||||
* @author Nicolas Renard
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface Heap {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the top element in the heap, the one with lowest key for min-heap or with
|
||||
* the highest key for max-heap
|
||||
* @throws Exception if heap is empty
|
||||
* @throws EmptyHeapException if heap is empty
|
||||
*/
|
||||
public abstract HeapElement getElement() throws EmptyHeapException;
|
||||
HeapElement getElement() throws EmptyHeapException;
|
||||
|
||||
/**
|
||||
* Inserts an element in the heap. Adds it to then end and toggle it until it finds its
|
||||
* right position.
|
||||
*
|
||||
*
|
||||
* @param element an instance of the HeapElement class.
|
||||
*/
|
||||
public abstract void insertElement(HeapElement element);
|
||||
|
||||
void insertElement(HeapElement element);
|
||||
|
||||
/**
|
||||
* Delete an element in the heap.
|
||||
*
|
||||
*
|
||||
* @param elementIndex int containing the position in the heap of the element to be deleted.
|
||||
*/
|
||||
public abstract void deleteElement(int elementIndex);
|
||||
void deleteElement(int elementIndex);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user