Interface HeapInterface<E>
- Type Parameters:
E- Type of elements stored in this heap
- All Known Implementing Classes:
Heap
public interface HeapInterface<E>
A generic heap.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified element to this heap.Returns the comparator used by this heap.booleanisEmpty()Returns true if there are no elements in this heap, false otherwise.remove()Removes and returns the element with the highest priority.intsize()Returns the number of elements stored in this heap.
-
Field Details
-
INITIAL_SIZE
static final int INITIAL_SIZEInitial size of the Heap.- See Also:
-
-
Method Details
-
add
Adds the specified element to this heap.- Parameters:
element- the element to add to this heap.
-
remove
Removes and returns the element with the highest priority.- Returns:
- element with the highest priority.
- Throws:
EmptyHeapException- when trying to remove from an empty heap.
-
size
int size()Returns the number of elements stored in this heap.- Returns:
- number of elements in this heap.
-
isEmpty
boolean isEmpty()Returns true if there are no elements in this heap, false otherwise.- Returns:
- true if there are no elements in this heap, false otherwise.
-
comparator
Comparator<E> comparator()Returns the comparator used by this heap.- Returns:
- the comparator used by this heap.
-