Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/rarfilesource.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOctaneSnail <os@v12pwr.com>2008-12-08 00:47:18 +0300
committerOctaneSnail <os@v12pwr.com>2008-12-08 00:47:18 +0300
commit2e08a75b5dfe105441bb985d0725b89749e4dcb3 (patch)
tree82c4c38817039551c50f6605ebc002413d1fd73e /List.cpp
Initial import of RARFileSource v0.8.
Diffstat (limited to 'List.cpp')
-rw-r--r--List.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/List.cpp b/List.cpp
new file mode 100644
index 0000000..18899b1
--- /dev/null
+++ b/List.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2008, OctaneSnail <os@v12pwr.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+template <class T> void List<T>::InsertFirst (Node<T> *n)
+{
+ n->next = anchor.next;
+ n->prev = &anchor;
+
+ anchor.next->prev = n;
+ anchor.next = n;
+}
+
+template <class T> void List<T>::InsertLast (Node<T> *n)
+{
+ n->next = &anchor;
+ n->prev = anchor.prev;
+
+ anchor.prev->next = n;
+ anchor.prev = n;
+}
+
+template <class T> T *List<T>::UnlinkFirst (void)
+{
+ Node<T> *n = First ();
+ if (!n)
+ return NULL;
+ n->Unlink ();
+ return (T *) n;
+}
+
+template <class T> T *List<T>::UnlinkLast (void)
+{
+ Node<T> *n = Last ();
+ if (!n)
+ return NULL;
+ n->Unlink ();
+ return (T *) n;
+}
+
+template <class T> T *List<T>::Next (Node<T> *n)
+{
+ if (n->next == &anchor)
+ return NULL;
+ return (T *) n->next;
+}
+
+template <class T> T *List<T>::Prev (Node<T> *n)
+{
+ if (n->prev == &anchor)
+ return NULL;
+ return (T *) n->prev;
+}
+
+template <class T> void List<T>::Clear ()
+{
+ T *node;
+
+ while (node = UnlinkFirst ())
+ delete node;
+}