Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.media.mn8.util.cron
Class BinaryHeap  view BinaryHeap download BinaryHeap.java

java.lang.Object
  extended byorg.media.mn8.util.cron.BinaryHeap

public final class BinaryHeap
extends java.lang.Object


Nested Class Summary
private static class BinaryHeap.MaxComparator
           
private static class BinaryHeap.MinComparator
           
 
Field Summary
private static int DEFAULT_CAPACITY
           
private static java.util.Comparator DEFAULT_COMPARATOR
           
private  java.util.Comparator m_comparator
           
private  java.lang.Object[] m_elements
           
private  int m_size
           
static java.util.Comparator MAX_COMPARATOR
           
static java.util.Comparator MIN_COMPARATOR
           
 
Constructor Summary
BinaryHeap()
           
BinaryHeap(int capacity, java.util.Comparator comparator)
           
 
Method Summary
 void clear()
          Clear all elements from queue.
private  void grow()
          Grows the heap by a factor of 2.
 void insert(java.lang.Object element)
          Insert an element into queue.
 boolean isEmpty()
          Test if queue is empty.
 boolean isFull()
          Test if queue is full.
 java.lang.Object peek()
          Return element on top of heap but don't remove it.
private  void percolateDownHeap(int index)
          Percolate element down heap from top.
private  void percolateUpHeap(java.lang.Object element)
          Percolate element up heap from bottom.
 java.lang.Object pop()
          Return element on top of heap and remove it.
 int size()
          Returns the number of elements currently on the heap.
 java.lang.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 java.util.Comparator MIN_COMPARATOR

MAX_COMPARATOR

public static final java.util.Comparator MAX_COMPARATOR

DEFAULT_CAPACITY

private static final int DEFAULT_CAPACITY
See Also:
Constant Field Values

DEFAULT_COMPARATOR

private static final java.util.Comparator DEFAULT_COMPARATOR

m_size

private int m_size

m_elements

private java.lang.Object[] m_elements

m_comparator

private java.util.Comparator m_comparator
Constructor Detail

BinaryHeap

public BinaryHeap()

BinaryHeap

public BinaryHeap(int capacity,
                  java.util.Comparator comparator)
Method Detail

clear

public void clear()
Clear all elements from queue.


isEmpty

public boolean isEmpty()
Test if queue is empty.


isFull

public boolean isFull()
Test if queue is full.


size

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


insert

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


peek

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


pop

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


percolateDownHeap

private void percolateDownHeap(int index)
Percolate element down heap from top.


percolateUpHeap

private void percolateUpHeap(java.lang.Object element)
Percolate element up heap from bottom.


grow

private void grow()
Grows the heap by a factor of 2.


toString

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