diff options
author | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2006-11-01 14:48:34 +0000 |
---|---|---|
committer | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2006-11-01 14:48:34 +0000 |
commit | d123e0ce94bf90b2adb0a4000930eb467e293226 (patch) | |
tree | d414dea59908105c4d2f256199a610e0a69c8690 /updater/common.cpp | |
parent | a13e82647294da4add976a24335fec50d7bfe905 (diff) |
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@16 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'updater/common.cpp')
-rw-r--r-- | updater/common.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/updater/common.cpp b/updater/common.cpp new file mode 100644 index 0000000..f7b240b --- /dev/null +++ b/updater/common.cpp @@ -0,0 +1,72 @@ +#include "common.h"
+
+UpdateList::UpdateList(): count(0), head(0), tail(0) {
+}
+
+UpdateList::~UpdateList() {
+ clear();
+}
+
+UpdateList::UpdateList(UpdateList &source): count(0), head(0), tail(0) {
+ for(source.reset(); source.current(); source.next())
+ push_back(*source.current());
+}
+
+void UpdateList::clear() {
+ Node *current;
+ while(head) {
+ current = head;
+ head = head->next;
+ delete current;
+ }
+
+ count = 0;
+ head = tail = 0;
+ reset();
+}
+
+int UpdateList::size() {
+ return count;
+}
+
+void UpdateList::reset() {
+ it_current = head;
+}
+
+void UpdateList::erase() {
+ if(it_current) {
+ if(head == it_current) head = head->next;
+ if(tail == it_current) tail = tail->prev;
+
+ if(it_current->next) it_current->next->prev = it_current->prev;
+ if(it_current->prev) it_current->prev->next = it_current->next;
+
+ delete it_current;
+ count--;
+ reset();
+ }
+}
+
+void UpdateList::next() {
+ if(it_current) it_current = (Node *)it_current->next;
+}
+
+UpdateInternal *UpdateList::current() {
+ return (it_current ? &it_current->ui : 0);
+}
+
+void UpdateList::push_back(UpdateInternal &update) {
+ if(tail) {
+ tail->next = new Node;
+ tail->next->prev = tail;
+ tail = tail->next;
+ } else {
+ head = tail = new Node;
+ }
+ tail->ui = update;
+ count++;
+}
+
+UpdateInternal &UpdateList::back() {
+ return tail->ui;
+}
|