From 833d20a69fe17ab846c153e35230c66a41d8fca9 Mon Sep 17 00:00:00 2001 From: Pixel <> Date: Wed, 28 Feb 2001 11:40:25 +0000 Subject: Premier jet --- include/PCommon.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 include/PCommon.h (limited to 'include/PCommon.h') diff --git a/include/PCommon.h b/include/PCommon.h new file mode 100644 index 0000000..1d90a21 --- /dev/null +++ b/include/PCommon.h @@ -0,0 +1,77 @@ +#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); + ~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 -- cgit v1.2.3