bamboo.lss
Class PriorityQueue

java.lang.Object
  extended by bamboo.lss.PriorityQueue

public class PriorityQueue
extends Object

A non-blocking priority queue.

Version:
$Id: PriorityQueue.java,v 1.7 2004/05/14 10:03:42 harlanyu Exp $
Author:
Westley Weimer

Field Summary
protected  int capacity
           
protected  Object[] heap
           
protected  int heap_size
           
protected  long[] prio
           
 
Constructor Summary
PriorityQueue(int initial_capacity)
          Creates a new priority queue with the give initial capacity.
 
Method Summary
 boolean add(Object o, long p)
          Adds an object with the given priority.
 boolean contains(Object o)
           
 Object getFirst()
           
 long getFirstPriority()
           
 Object getIndex(int i)
           
 long getIndexPriority(int i)
           
 boolean isEmpty()
           
 Object removeFirst()
           
 int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

heap

protected Object[] heap

prio

protected long[] prio

capacity

protected int capacity

heap_size

protected int heap_size
Constructor Detail

PriorityQueue

public PriorityQueue(int initial_capacity)
Creates a new priority queue with the give initial capacity.

Method Detail

size

public final int size()

isEmpty

public final boolean isEmpty()

add

public final boolean add(Object o,
                         long p)
Adds an object with the given priority.


getFirstPriority

public final long getFirstPriority()

getFirst

public final Object getFirst()

getIndexPriority

public final long getIndexPriority(int i)

getIndex

public final Object getIndex(int i)

contains

public final boolean contains(Object o)

removeFirst

public final Object removeFirst()

toString

public String toString()
Overrides:
toString in class Object