libsaria: Initialize list objects
I point the list head towards itself. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
4aac603b85
commit
da776eeebf
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
Loading…
Reference in New Issue