edu.ucla.structure
Class Heap

Object
  extended by Heap

public class Heap
extends Object

A class implementing a binary heap.


Nested Class Summary
static class Heap.HeapElement
          Helper class for implementing an object priority pair.
 
Constructor Summary
Heap()
          Creates an empty heap.
Heap(Object[] objs, double[] scores)
          Creates a heap consisting made up of the objects, with corresponding priorities.
 
Method Summary
 Heap.HeapElement extractMax()
          Removes the highest priority element and returns it along with its priority.
 void insert(Object obj, double score)
          Adds element to heap.
 boolean isEmpty()
          Returns whether or not the heap is empty.
 double maxScore()
          Returns the maximum score in the heap.
 void setValue(Object obj, double score)
          Modifies the priority of one of the heap elements.
 int size()
          Returns the number of elements currently in the heap.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Heap

public Heap()
Creates an empty heap.


Heap

public Heap(Object[] objs,
            double[] scores)
Creates a heap consisting made up of the objects, with corresponding priorities.

Method Detail

insert

public void insert(Object obj,
                   double score)
Adds element to heap.


setValue

public void setValue(Object obj,
                     double score)
Modifies the priority of one of the heap elements.


isEmpty

public boolean isEmpty()
Returns whether or not the heap is empty.


size

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


extractMax

public Heap.HeapElement extractMax()
Removes the highest priority element and returns it along with its priority.


maxScore

public double maxScore()
Returns the maximum score in the heap. Added by Mark Chavira 2004-06-17.



Copyright 2010 UCLA Automated Reasoning Group