diff options
author | Alexis211 <alexis211@gmail.com> | 2009-10-11 21:58:04 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-10-11 21:58:04 +0200 |
commit | 277d5fcb3b378089c0f3390a0b4d1b529075958a (patch) | |
tree | dfc70f3636c3e4192785c4e052986383a3761a5c /Source/Kernel/Library | |
parent | 4f1c0997990e719ac1a1cfcb80a7437009c46b7b (diff) | |
download | Melon-277d5fcb3b378089c0f3390a0b4d1b529075958a.tar.gz Melon-277d5fcb3b378089c0f3390a0b4d1b529075958a.zip |
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.
Diffstat (limited to 'Source/Kernel/Library')
-rw-r--r-- | Source/Kernel/Library/SimpleList.class.h | 11 |
1 files changed, 11 insertions, 0 deletions
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<T>* removeOnce(const T& value) { + if (value == m_value) return delThis(); + for (SimpleList<T> *iter = this; iter->next() != 0; iter = iter->next()) { + if (iter->next()->v() == value) { + iter->delNext(); + break; + } + } + return this; + } + bool isEnd() { return m_next == 0; } |