org.media.mn8.util.cron
Class BinaryHeap

java.lang.Object
  |
  +--org.media.mn8.util.cron.BinaryHeap

public final class BinaryHeap
extends Object


Field Summary
static Comparator MAX_COMPARATOR
           
static Comparator MIN_COMPARATOR
           
 
Constructor Summary
BinaryHeap()
           
BinaryHeap(int capacity, Comparator comparator)
           
 
Method Summary
 void clear()
          Clear all elements from queue.
 void insert(Object element)
          Insert an element into queue.
 boolean isEmpty()
          Test if queue is empty.
 boolean isFull()
          Test if queue is full.
 Object peek()
          Return element on top of heap but don't remove it.
 Object pop()
          Return element on top of heap and remove it.
 int size()
          Returns the number of elements currently on the heap.
 String toString()
          Create a string representing heap and all elements in heap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_COMPARATOR

public static final Comparator MIN_COMPARATOR

MAX_COMPARATOR

public static final Comparator MAX_COMPARATOR
Constructor Detail

BinaryHeap

public BinaryHeap()

BinaryHeap

public BinaryHeap(int capacity,
                  Comparator comparator)
Method Detail

clear

public void clear()
Clear all elements from queue.


isEmpty

public boolean isEmpty()
Test if queue is empty.

Returns:
true if queue is empty else false.

isFull

public boolean isFull()
Test if queue is full.

Returns:
true if queue is full else false.

size

public int size()
Returns the number of elements currently on the heap.

Returns:
the size of the heap.

insert

public void insert(Object element)
Insert an element into queue.

Parameters:
element - the element to be inserted

peek

public Object peek()
            throws NoSuchElementException
Return element on top of heap but don't remove it.

Returns:
the element at top of heap
Throws:
NoSuchElementException - if isEmpty() == true

pop

public Object pop()
           throws NoSuchElementException
Return element on top of heap and remove it.

Returns:
the element at top of heap
Throws:
NoSuchElementException - if isEmpty() == true

toString

public String toString()
Create a string representing heap and all elements in heap.

Overrides:
toString in class Object
Returns:
the string representing heap


"Copyright © 2000-2002 Internet Multicasting Services, media.org & noLimits Technologies. All Rights Reserved."