diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2002-05-12 14:46:46 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2002-05-12 14:46:46 +0200 |
commit | 2cc450a67cd8c5bef3f0b568735e5bb7efde660a (patch) | |
tree | 85a6a3629a5171903663f29606e747f90d609892 /tools.c | |
parent | 97a5ac7cba7eccbabc757fc46d62bbb3786b94fc (diff) | |
download | vdr-2cc450a67cd8c5bef3f0b568735e5bb7efde660a.tar.gz vdr-2cc450a67cd8c5bef3f0b568735e5bb7efde660a.tar.bz2 |
Added 'insert' capabilities to cList
Diffstat (limited to 'tools.c')
-rw-r--r-- | tools.c | 42 |
1 files changed, 35 insertions, 7 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.63 2002/05/01 16:20:30 kls Exp $ + * $Id: tools.c 1.64 2002/05/12 11:37:24 kls Exp $ */ #include "tools.h" @@ -724,6 +724,12 @@ void cListObject::Append(cListObject *Object) Object->prev = this; } +void cListObject::Insert(cListObject *Object) +{ + prev = Object; + Object->next = this; +} + void cListObject::Unlink(void) { if (next) @@ -757,13 +763,35 @@ cListBase::~cListBase() Clear(); } -void cListBase::Add(cListObject *Object) +void cListBase::Add(cListObject *Object, cListObject *After) { - if (lastObject) - lastObject->Append(Object); - else - objects = Object; - lastObject = Object; + if (After && After != lastObject) { + After->Next()->Insert(Object); + After->Append(Object); + } + else { + if (lastObject) + lastObject->Append(Object); + else + objects = Object; + lastObject = Object; + } +} + +void cListBase::Ins(cListObject *Object, cListObject *Before) +{ + if (Before && Before != objects) { + Before->Prev()->Append(Object); + Before->Insert(Object); + } + else { + if (objects) + objects->Insert(Object); + else + objects = Object; + if (!lastObject) + lastObject = Object; + } } void cListBase::Del(cListObject *Object) |