PairingHeap.h revision 9765928d461305451eb6199a1a9417e09549dee9
/**
* \brief Pairing heap datastructure implementation
*
* Based on example code in "Data structures and Algorithm Analysis in C++"
* by Mark Allen Weiss, used and released under the GPL by permission
* of the author.
*
* No promises about correctness. Use at your own risk!
*
* Authors:
* Mark Allen Weiss
* Tim Dwyer <tgdwyer@gmail.com>
*
* Copyright (C) 2005 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#ifndef PAIRING_HEAP_H_
#define PAIRING_HEAP_H_
#include <stdlib.h>
#include <fstream>
// Pairing heap class
//
// CONSTRUCTION: with no parameters
//
// ******************PUBLIC OPERATIONS*********************
// PairNode & insert( x ) --> Insert x
// deleteMin( minItem ) --> Remove (and optionally return) smallest item
// T findMin( ) --> Return smallest item
// bool isEmpty( ) --> Return true if empty; else false
// bool isFull( ) --> Return true if empty; else false
// void makeEmpty( ) --> Remove all items
// void decreaseKey( PairNode p, newVal )
// --> Decrease value in node p
// ******************ERRORS********************************
// Throws Underflow as warranted
// Node and forward declaration because g++ does
// not understand nested classes.
{
T element;
PairNode( const T & theElement ) :
element( theElement ),
{ }
};
{
};
{
~PairingHeap( );
bool isEmpty( ) const;
bool isFull( ) const;
int size();
const T & findMin( ) const;
void deleteMin( );
void makeEmpty( );
{
}
} else {
}
}
return r;
}
int counter;
void reclaimMemory( PairNode<T> *t ) const;
};
#include "PairingHeap.cpp"
#endif