summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-05-12 14:46:46 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2002-05-12 14:46:46 +0200
commit2cc450a67cd8c5bef3f0b568735e5bb7efde660a (patch)
tree85a6a3629a5171903663f29606e747f90d609892 /tools.c
parent97a5ac7cba7eccbabc757fc46d62bbb3786b94fc (diff)
downloadvdr-2cc450a67cd8c5bef3f0b568735e5bb7efde660a.tar.gz
vdr-2cc450a67cd8c5bef3f0b568735e5bb7efde660a.tar.bz2
Added 'insert' capabilities to cList
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/tools.c b/tools.c
index 6f99ef09..ef37dfda 100644
--- a/tools.c
+++ b/tools.c
@@ -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)