Main Page   Class Hierarchy   Compound List   File List   Compound Members  

MinPriorityQueue< T > Class Template Reference

#include <MinPriorityQueue.hh>

Inheritance diagram for MinPriorityQueue< T >:

HeapMin< T > List of all members.

Public Methods

 MinPriorityQueue (T init)
 MinPriorityQueue (T init, int)
void insertKeyInQueue (T)
void printQueue ()
bool emptyQueue ()
void setQueueValue (int)
extractRoot ()
void deleteKey (int key)
void changeKey (int key,T newValue)

Detailed Description

template<class T>
class MinPriorityQueue< T >

This template class realizes a min-priority queue that's based on a heap. Therefore this template class is derived privately from template <class T> class HeapMin, i.e. the lowest value is placed on the root (and the heap condition of HeapMin is obtained). So the construction is based on a HeapMin<T> and the main methods do already exists in HeapMin. The first two methods are constructors just calling the constructors of HeapMin. There's no further destructor needed - default destructor is okay. The additional methods to realize a priority queue are: extractRoot() To return and cut the root of the heap; deleteKey(int key) To extract the node with number key;. changeKey(int key ,T newValue) Here you can change the value of the node key to newValue. The other methods are just calling the corresponding method of HeapMin<T>. You can't see any variables in this template, but you can reach the private variables of template class HeapMin by using the methods: void setValue(int); void increaseNumberOfNodes(); void decreaseNumberOfNodes(); int getNumberOfNodes(); How they work please read in the descprition of template <class T> class HeapMin


Constructor & Destructor Documentation

template<class T>
MinPriorityQueue< T >::MinPriorityQueue   init [inline]
 

Constructor which is calling constructor HeapMin<T>::HeapMin(T init)

Parameters:
init  It's the input value to initialize the array.

template<class T>
MinPriorityQueue< T >::MinPriorityQueue   init,
int   
[inline]
 

Constructor which is calls constructor HeapMin<T>::HeapMin(T init,int _value)

Parameters:
init  It's the input value to initialize the array.
_value  It's the input to set the variable m_value.


Member Function Documentation

template<class T>
void MinPriorityQueue< T >::changeKey int    key,
  newValue
[inline]
 

Method to change the value of a member key to newValue. First there runs an area check whether the chosen key is in the admissable area or not. If the check is negative there will be the answer: "The chosen key is out of the admissable area" and there will be nothing more done.If the check is positive the value of the declared key will be changed to newValue and the heap condition will be reestablished.

Parameters:
key  It's the key of which the value should be changed.
newValue  It's the new to be given value of the declared key.

template<class T>
void MinPriorityQueue< T >::deleteKey int    key [inline]
 

Method to delete a member key of the heap. First there runs an area check whether the chosen key is in the admissable area or not. If the check is negative there will be the answer: "The chosen key is out of the admissable area" and there will be nothing more done. If the check is positive the key will be deleted and the heap condition will be reestablished.

Parameters:
key  It's input key that should be deleted.

template<class T>
bool MinPriorityQueue< T >::emptyQueue   [inline]
 

Method to check whether the queue is empty or not by calling HeapMin<T>::emptyHeap().

Returns :
bool You get true if the heap is empty and false if the heap isn't empty. (ref. HeapMin<T>::emptyHeap())

template<class T>
T MinPriorityQueue< T >::extractRoot   [inline]
 

This method extracts the root of the heap.

Returns :
T It's the extracted (and by it deleted) top of the heap.

template<class T>
void MinPriorityQueue< T >::insertKeyInQueue   [inline]
 

Method to insert a new key value by calling HeapMin<T>::insertKey(T _value).

Parameters:
_value  It's the new value from datatype T that should be insert to the heap.

template<class T>
void MinPriorityQueue< T >::printQueue   [inline]
 

Method to print the queue by calling void HeapMin<T>::printHeap().

template<class T>
void MinPriorityQueue< T >::setQueueValue int    [inline]
 

With this method you are able to re-set the variable m_value of HeapMin<T> by calling void HeapMin<T>::setValue(int _value) which is responsible for the size of the field allocation (ref. void HeapMin<T>::setValue(int _value)).

Parameters:
reset  It's the future set of the variable m_value.


The documentation for this class was generated from the following file:
Generated on Sun Mar 9 11:43:45 2003 by doxygen1.2.17