cornell.cs211
Interface Heap<E>

Type Parameters:
E - The type of the elements held in this heap.
All Superinterfaces:
java.util.Collection<E>, java.lang.Iterable<E>
All Known Implementing Classes:
AbstractHeap, SortedHeap, StdHeap, UnsortedHeap

public interface Heap<E>
extends java.util.Collection<E>

This interface for Heap, integrated into the java Collection framwork. Besides basic Collection operations, Heap provide additional pop(), push(E), and top() operations.

Since:
1.5
Author:
Changxi Zheng
See Also:
AbstractHeap

Method Summary
 E pop()
          Retrieves and removes the head of this heap if exsits.
 boolean push(E o)
          Insert the specified element into the heap.
 E top()
          Retrieves but doesn't remove the head of this heap, or null if this heap is empty.
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

pop

E pop()
Retrieves and removes the head of this heap if exsits. Otherwise, do nothing and return null.

Returns:
the head of the heap, or null if this heap is empty.

top

E top()
Retrieves but doesn't remove the head of this heap, or null if this heap is empty.

Returns:
the head of the heap, or null if this heap is empty.

push

boolean push(E o)
Insert the specified element into the heap. This method is generally preferable to method Collection.add(E).

Parameters:
o - the element to insert
Returns:
true if it adds the element in the heap successfully, false otherwise.