#include #include "config.h" #include "CList.h" CList::CList(CList * IPoint, Datas_t IDatas, Key_t IKey):Left(IPoint), Right(IPoint->Right), Key(IKey), Datas(IDatas) { Left->Right = this; if (Right) Right->Left = this; } CList::CList(void):Left(NULL), Right(NULL), Key(0), Datas(NULL) { } CList::~CList(void) { if (Right) delete Right; } Datas_t CList::ReadDatas(Cell C) { return ((CList *) C)->Datas; } Key_t CList::ReadKey(Cell C) { return ((CList *) C)->Key; } Cell CList::Insert(Key_t IKey, Datas_t const &IDatas) { return (new CList(this, IDatas, IKey)); } Key_t CList::Delete(Datas_t & Datas, Cell C) { Key_t K; CList *x = ((CList *) C); if (x->Left) x->Left->Right = x->Right; if (x->Right) x->Right->Left = x->Left; Datas = x->Datas; K = x->Key; x->Right = NULL; delete x; return K; } Cell CList::GetFirst(void) { return Right; } Key_t CList::Pop(Datas_t & Datas) { return Delete(Datas, GetFirst()); }