Interface Heap<T extends java.lang.Comparable<? super T>>

Type Parameters:
T - the type of data the heap stores.

public interface Heap<T extends java.lang.Comparable<? super T>>

An interface for the Max-Heap ADT. Note that the ordering of elements is determined with the T.compareTo() method.


Method Summary
 void add(T item)
          Adds the given item to the heap.
 void clear()
          Removes all items from the heap.
 boolean isEmpty()
          Returns true if the heap is empty.
 T peek()
          Returns the maximum value, but doesn't change the heap.
 T removeRoot()
          Removes and returns the maximum value in the heap.
 

Method Detail

add

void add(T item)
Adds the given item to the heap.


removeRoot

T removeRoot()
Removes and returns the maximum value in the heap.

Returns:
null if the heap is empty.

peek

T peek()
Returns the maximum value, but doesn't change the heap.

Returns:
null if the heap is empty.

isEmpty

boolean isEmpty()
Returns true if the heap is empty.


clear

void clear()
Removes all items from the heap.