libsaria: Initialize list objects

I point the list head towards itself.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-06-14 08:11:16 -04:00
parent 4aac603b85
commit da776eeebf
2 changed files with 33 additions and 0 deletions

View File

@ -9,6 +9,7 @@ namespace libsaria
template <class T>
class ListNode {
friend class List<T>;
private:
ListNode *prev;
ListNode *next;
@ -24,11 +25,17 @@ namespace libsaria
template <class T>
class List {
private:
unsigned int count;
ListNode<T> head;
public:
List();
~List();
};
};
#include "../../libsaria/list/node.cpp"
#include "../../libsaria/list/list.cpp"
#endif /* LIBSARIA_LIST_H */

26
libsaria/list/list.cpp Normal file
View File

@ -0,0 +1,26 @@
// Copyright (c) 2012 Bryan Schumaker.
#ifndef LIBSARIA_LIST_CPP
#define LIBSARIA_LIST_CPP
#include <libsaria/list.h>
namespace libsaria
{
template <class T>
List<T>::List()
{
count = 0;
head.prev = &head;
head.next = &head;
head.list = this;
}
template <class T>
List<T>::~List()
{
}
}
#endif /* LIBSARIA_LIST_CPP */