00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _FLL_H
00014 #define _FLL_H
00015
00016 #include <cstdlib>
00017 #include <cassert>
00018 #include <MemList.hpp>
00019
00020 template <class Type> class FastList;
00021
00022 template <class Type>
00023 class FLL {
00024 public:
00025 friend class FastList<Type>;
00026
00027 FLL() : data(NULL), next(NULL) {}
00028 FLL(Type &d) : data(&d), next(NULL) {}
00029 FLL(Type &d, FLL<Type> *pNext) : data(&d), next(pNext) {}
00030 ~FLL() {}
00031
00032 FLL<Type> *Next() const { return next; }
00033 void Replace(Type &newData) { data = &newData; }
00034 Type &Data() const { return *data; }
00035
00036 private:
00037 Type *data;
00038 FLL<Type> *next;
00039
00040
00041 FLL(const FLL &) { assert(0); }
00042 FLL &operator=(const FLL &) { assert(0); return *this; }
00043 int operator==(const FLL &x) const { return this == &x; }
00044
00045 public:
00046 void *operator new(size_t size) { return pMemList->GetMem(size); }
00047 void operator delete(void *) { }
00048 static void UseMemory(MemList &memList) { pMemList = &memList; }
00049
00050 private:
00051 static MemList *pMemList;
00052 };
00053
00054 #endif