BRUtil - Making Java a Kinder, Gentler, Place to be.

brutil
Class PriorityQueueRadix

java.lang.Object
  |
  +--brutil.PriorityQueueRadix

public class PriorityQueueRadix
extends java.lang.Object


Constructor Summary
PriorityQueueRadix(int keySize)
           
 
Method Summary
 boolean decreaseKey(HandlePQ key, int newKey)
          Decreases the key value of the specified element.
 HandlePQ extractMin()
          Extracts the object with the smallest key value from the array Then the array is traversed to find the next smallest key
 HandlePQ insert(int key, java.lang.Object value)
          Appends a wrapper object with the value and its key to a list in the array The key is used as the radix postion of the array.
 boolean isEmpty()
          Returns true if the Priority Queue is empty
 HandlePQ min()
          Returns the smallest key value in the Priority Queue
 java.lang.String toString()
          Return a list of element stored inside the Priority Queue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PriorityQueueRadix

public PriorityQueueRadix(int keySize)
Method Detail

insert

public HandlePQ insert(int key,
                       java.lang.Object value)
Appends a wrapper object with the value and its key to a list in the array The key is used as the radix postion of the array. Also, we keep track of the lowest key value inserted into the array
Parameters:
key - the key value of the object
value - the object to be stored in the queue
Returns:
the wrapper object the holds the key and the object values

min

public HandlePQ min()
Returns the smallest key value in the Priority Queue
Returns:
the object with the smallest key value in the Priority Queue

extractMin

public HandlePQ extractMin()
Extracts the object with the smallest key value from the array Then the array is traversed to find the next smallest key
Returns:
the wrapper object with the smallest key value

decreaseKey

public boolean decreaseKey(HandlePQ key,
                           int newKey)
Decreases the key value of the specified element. If the newKey is >= the current key value, false is returned.
Parameters:
h - the HandlePQ whose key value needs to be modified
newKey - the new value
Returns:
true if the key value was changes successfuly, false if the key value was not decreased.

isEmpty

public boolean isEmpty()
Returns true if the Priority Queue is empty
Returns:
true if there are no elements in the Priority Queue

toString

public java.lang.String toString()
Return a list of element stored inside the Priority Queue
Overrides:
toString in class java.lang.Object
Returns:
string value of all the elements in the queue


BRUtil - Making Java a Kinder, Gentler, Place to be.