Interface CS20Heap


public interface CS20Heap

Heap interface for CS 20 assignment 3, part 1, Summer 2009. A heap for String data that can function as either a max or min heap. Should have no capacity constraint.


Field Summary
static int INITIAL_CAPACITY
          Intended as the initial capacity of array used to implement the heap; and if array is filled, then capacity should be increased by this amount to allow unlimited inserts.
 
Method Summary
 void clear()
          Makes the heap logically empty.
 void insert(String item)
          Insert item, maintaining heap order.
 boolean isEmpty()
          Tests if the heap is logically empty.
 String removeTop()
          Removes the top item from the heap, maintaining heap order.
 int size()
          Return the size of the heap.
 String top()
          Returns top item on heap, without removing it.
 

Field Detail

INITIAL_CAPACITY

static final int INITIAL_CAPACITY
Intended as the initial capacity of array used to implement the heap; and if array is filled, then capacity should be increased by this amount to allow unlimited inserts.

See Also:
Constant Field Values
Method Detail

insert

void insert(String item)
Insert item, maintaining heap order. Duplicates are allowed.

Parameters:
item - the item to insert.

top

String top()
Returns top item on heap, without removing it.

Returns:
the top item, or null if heap is empty.

removeTop

String removeTop()
Removes the top item from the heap, maintaining heap order.

Returns:
the top item, or null if empty.

size

int size()
Return the size of the heap.

Returns:
the current number of items in the heap.

isEmpty

boolean isEmpty()
Tests if the heap is logically empty.

Returns:
true if empty, false otherwise.

clear

void clear()
Makes the heap logically empty.