Main Page   Class Hierarchy   Compound List   File List   Compound Members  

MaxPriorityQueue< T > Class Template Reference

#include <MaxPriorityQueue.hh>

Inheritance diagram for MaxPriorityQueue< T >:

HeapMax< T > List of all members.

Public Methods

 MaxPriorityQueue (T init)
 MaxPriorityQueue (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 MaxPriorityQueue< T >

This template class realizes a max-priority queue that's based on a heap. Therefore this template class is derived privately from template <class T> class HeapMax, i.e. the biggest value is placed on the root (and the heap condition of HeapMax is obtained). So the construction is based on a HeapMax<T> and the main methods do already exists in HeapMax. The first two methods are constructors just calling the constructors of HeapMax. 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 HeapMax<T>. You can't see any variables in this template, but you can reach the private variables of template class HeapMax 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 HeapMax.


Constructor & Destructor Documentation

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

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

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

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

Constructor which calls constructor HeapMax<T>::HeapMax(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 MaxPriorityQueue< 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 MaxPriorityQueue< 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 MaxPriorityQueue< T >::emptyQueue   [inline]
 

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

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

template<class T>
T MaxPriorityQueue< 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 MaxPriorityQueue< T >::insertKeyInQueue   [inline]
 

Method to insert a new key value by calling HeapMax<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 MaxPriorityQueue< T >::printQueue   [inline]
 

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

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

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