From 277d5fcb3b378089c0f3390a0b4d1b529075958a Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sun, 11 Oct 2009 21:58:04 +0200 Subject: SimpleList now implements removeOnce(const T& value); This methods searches for value in the list and removes it from the list. Only the first occurrence will be removed. --- Source/Kernel/Library/SimpleList.class.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Source/Kernel/Library') diff --git a/Source/Kernel/Library/SimpleList.class.h b/Source/Kernel/Library/SimpleList.class.h index 770128e..64e37aa 100644 --- a/Source/Kernel/Library/SimpleList.class.h +++ b/Source/Kernel/Library/SimpleList.class.h @@ -45,6 +45,17 @@ class SimpleList { Mem::kfree(temp); } + SimpleList* removeOnce(const T& value) { + if (value == m_value) return delThis(); + for (SimpleList *iter = this; iter->next() != 0; iter = iter->next()) { + if (iter->next()->v() == value) { + iter->delNext(); + break; + } + } + return this; + } + bool isEnd() { return m_next == 0; } -- cgit v1.2.3