summaryrefslogtreecommitdiff
path: root/include/PCommon.h
diff options
context:
space:
mode:
authorPixel <>2001-02-28 11:40:25 +0000
committerPixel <>2001-02-28 11:40:25 +0000
commit833d20a69fe17ab846c153e35230c66a41d8fca9 (patch)
tree180ba073e59fee8df22cb733be2eec4c452e1b85 /include/PCommon.h
Premier jetstart
Diffstat (limited to 'include/PCommon.h')
-rw-r--r--include/PCommon.h77
1 files changed, 77 insertions, 0 deletions
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 <PTypes.h>
+#include <limits.h>
+#define P_INFINITY INT_MAX
+#define M_INFINITY INT_MIN
+void exception(int e, char *msg);
+
+#ifdef __cplusplus
+#include <iostream.h>
+
+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