Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » util » [javadoc | source]
org.jboss.util
public class: Heap [javadoc | source]
java.lang.Object
   org.jboss.util.Heap
Data structure that mantains data in a ordered binary tree; each node is greater (smaller) or equal than its 2 sub-nodes, for all the hierarchy.

Elements of this data structure should either implement Comparable, or a Comparator should be given as argument to the constructor.

Constructor:
 public Heap() 
 public Heap(Comparator comparator) 
    Creates a new Heap whose elements are compared using the given Comparator .
Method from org.jboss.util.Heap Summary:
clear,   compare,   extract,   insert,   left,   parent,   peek,   right
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jboss.util.Heap Detail:
 public  void clear() 
    Empties this heap
 protected int compare(Object o1,
    Object o2) 
    Compares the given objects using the comparator, if available, or considering them Comparable objects.
 public Object extract() 
    Removes and returns the least element of this heap.
 public  void insert(Object obj) 
    Inserts the given element in this heap.
 protected int left(int index) 
    Returns the left child index of index.
 protected int parent(int index) 
    Returns the parent index of index.
 public Object peek() 
    Returns, without removing it, the least element of this heap.
 protected int right(int index) 
    Returns the right child index of index.