diff options
author | Pixel <> | 2001-02-28 11:40:25 +0000 |
---|---|---|
committer | Pixel <> | 2001-02-28 11:40:25 +0000 |
commit | 833d20a69fe17ab846c153e35230c66a41d8fca9 (patch) | |
tree | 180ba073e59fee8df22cb733be2eec4c452e1b85 /lib/CList.cc |
Premier jetstart
Diffstat (limited to 'lib/CList.cc')
-rw-r--r-- | lib/CList.cc | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/CList.cc b/lib/CList.cc new file mode 100644 index 0000000..c54e6e1 --- /dev/null +++ b/lib/CList.cc @@ -0,0 +1,62 @@ +#include <stdio.h> +#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()); +} |