Package com.javaholics
Interface MaxHeapInterface<T extends Comparable<? super T>>
- All Known Implementing Classes:
MaxHeap
public interface MaxHeapInterface<T extends Comparable<? super T>>
An interface for the ADT maxheap.
- Version:
- 1.0
- Author:
- Lindsay Kilingbury, Lea Wiranatha
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new entry to this heap.void
clear()
Removes all entries from this heap.getMax()
Retrieves the largest item in this heap.int
getSize()
Gets the size of this heap.boolean
isEmpty()
Detects whether this heap is empty.Removes and returns the largest item in this heap.
-
Method Details
-
add
Adds a new entry to this heap.- Parameters:
newEntry
- An object to be added.
-
removeMax
T removeMax()Removes and returns the largest item in this heap.- Returns:
- Either the largest object in the heap or, if the heap is empty before the operation, null.
-
getMax
T getMax()Retrieves the largest item in this heap.- Returns:
- Either the largest object in the heap or, if the heap is empty, null.
-
isEmpty
boolean isEmpty()Detects whether this heap is empty.- Returns:
- True if the heap is empty, or false otherwise.
-
getSize
int getSize()Gets the size of this heap.- Returns:
- The number of entries currently in the heap.
-
clear
void clear()Removes all entries from this heap.
-