#ifndef __PCOMMON_H__ #define __PCOMMON_H__ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef _ #define _(x) x #endif #include #include #define P_INFINITY INT_MAX #define M_INFINITY INT_MIN void exception(int e, char *msg); #ifdef __cplusplus #include class PriorityList { protected: class GeneralException; int type; Key_t Key; Datas_t Datas; PriorityList(Key_t IKey, Datas_t const &IDatas); public: PriorityList(void); virtual ~PriorityList(void); virtual Key_t ReadKey(Cell C); virtual Datas_t ReadDatas(Cell C); virtual int n(void); virtual int rn(void) = 0; virtual void Dump(ostream & os) = 0; virtual bool IsEmpty(void) = 0; virtual Cell Min(void) = 0; virtual Cell Insert(Key_t IKey, Datas_t const &IDatas) = 0; virtual Key_t Extract_Min(Datas_t & Datas) = 0; virtual PriorityList *Union(PriorityList * P) = 0; virtual bool Lower_Key(Cell x, Key_t NKey) = 0; virtual Key_t Delete(Datas_t & Datas, Cell x) = 0; PriorityList *GenericUnion(PriorityList * P); int GetType(void); }; #ifndef SWAP template < class T > inline void SWAP(T & a, T & b) { T tmp(a); a = b; b = tmp; }; #endif #else #warning This librairy is only designed for a C++ compiler. #ifndef SWAP #define SWAP(a,b) { \ char T[sizeof(a)]; \ memcpy(T, &a, sizeof(a)); \ memcpy(&a, &b, sizeof(a)); \ memcpy(&b, T, sizeof(a)); \ } #endif #endif #ifdef DEBUG extern int nc, nd; #endif #endif