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
path: root/List.h
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.h
Initial import of RARFileSource v0.8.
Diffstat (limited to 'List.h')
-rw-r--r--List.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/List.h b/List.h
new file mode 100644
index 0000000..e32c4f8
--- /dev/null
+++ b/List.h
@@ -0,0 +1,69 @@
+/*
+ * 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/>.
+ */
+
+#ifndef LIST_H
+#define LIST_H
+
+template <class T> class List;
+
+template <class T> class Node
+{
+ friend class List<T>;
+
+public:
+ Node (void) : next (NULL), prev (NULL) { }
+
+ void Unlink (void)
+ {
+ next->prev = prev;
+ prev->next = next;
+ }
+
+private:
+ Node (Node *next, Node *prev) : next (next), prev (prev) { }
+
+ Node *next;
+ Node *prev;
+};
+
+template <class T> class List
+{
+public:
+ List (void) : anchor (&anchor, &anchor) { }
+
+ bool IsEmpty (void) { return anchor.next == &anchor; }
+
+ T *First (void) { return Next (&anchor); }
+ T *Last (void) { return Prev (&anchor); }
+
+ void InsertFirst (Node<T> *n);
+ void InsertLast (Node<T> *n);
+
+ T *UnlinkFirst (void);
+ T *UnlinkLast (void);
+
+ T *Next (Node<T> *n);
+ T *Prev (Node<T> *n);
+
+ void Clear (void);
+
+private:
+ Node<T> anchor;
+};
+
+#include "List.cpp"
+
+#endif // LIST_H