Rudiments

- Main Page
- Classes

singlylinkedlist.h
1 // Copyright (c) 2014 David Muse
2 // See the COPYING file for more information.
3
4 #ifndef RUDIMENTS_SINGLYLINKEDLIST_H
5 #define RUDIMENTS_SINGLYLINKEDLIST_H
6
7 #include <rudiments/private/singlylinkedlistincludes.h>
8
11 template <class valuetype>
12 class singlylinkedlistnode {
13 public:
16 singlylinkedlistnode(valuetype value);
17
21 virtual ~singlylinkedlistnode();
22
24 void setValue(valuetype value);
25
27 valuetype getValue() const;
28
32 int32_t compare(valuetype value) const;
33
38 int32_t compare(singlylinkedlistnode<valuetype> *peer) const;
39
42 singlylinkedlistnode<valuetype> *getNext();
43
45 void print() const;
46
47 #include <rudiments/private/singlylinkedlistnode.h>
48 };
49
63 template < class valuetype >
64 class singlylinkedlist {
65 public:
67 singlylinkedlist();
68
73 virtual ~singlylinkedlist();
74
77 void prepend(valuetype value);
78
81 void prepend(singlylinkedlistnode<valuetype> *node);
82
85 void append(valuetype value);
86
89 void append(singlylinkedlistnode<valuetype> *node);
90
93 void insertAfter(singlylinkedlistnode<valuetype> *node,
94 valuetype value);
95
98 void insertAfter(singlylinkedlistnode<valuetype> *node,
99 singlylinkedlistnode<valuetype> *newnode);
100
107 void moveAfter(singlylinkedlistnode<valuetype> *node,
108 singlylinkedlistnode<valuetype> *nodetomove);
109
115 void detach(singlylinkedlistnode<valuetype> *node);
116
124 bool remove(valuetype value);
125
133 bool removeAll(valuetype value);
134
143 bool remove(singlylinkedlistnode<valuetype> *node);
144
146 uint64_t getLength() const;
147
149 singlylinkedlistnode<valuetype> *getFirst();
150
152 singlylinkedlistnode<valuetype> *getLast();
153
157 singlylinkedlistnode<valuetype> *getNext(
158 singlylinkedlistnode<valuetype> *node);
159
162 singlylinkedlistnode<valuetype> *find(valuetype value);
163
167 singlylinkedlistnode<valuetype>
168 *find(singlylinkedlistnode<valuetype> *startnode,
169 valuetype value);
170
174 void insertionSort();
175
180 void heapSort();
181
185 void clear();
186
188 void print() const;
189
192 void print(uint64_t count) const;
193
194 #include <rudiments/private/singlylinkedlist.h>
195 };
196
197
198 #include <rudiments/private/singlylinkedlistinlines.h>
199
200 #endif
singlylinkedlistnode::getValue
valuetype getValue() const
singlylinkedlistnode::getNext
singlylinkedlistnode< valuetype > * getNext()
singlylinkedlistnode::singlylinkedlistnode
singlylinkedlistnode(valuetype value)
singlylinkedlist::singlylinkedlist
singlylinkedlist()
singlylinkedlist::getNext
singlylinkedlistnode< valuetype > * getNext(singlylinkedlistnode< valuetype > *node)
singlylinkedlistnode::print
void print() const
singlylinkedlist::print
void print() const
singlylinkedlist::append
void append(valuetype value)
singlylinkedlist::removeAll
bool removeAll(valuetype value)
singlylinkedlist::getLength
uint64_t getLength() const
singlylinkedlist
Definition: singlylinkedlist.h:64
singlylinkedlist::getFirst
singlylinkedlistnode< valuetype > * getFirst()
singlylinkedlist::find
singlylinkedlistnode< valuetype > * find(valuetype value)
singlylinkedlistnode::setValue
void setValue(valuetype value)
singlylinkedlist::prepend
void prepend(valuetype value)
singlylinkedlist::heapSort
void heapSort()
singlylinkedlist::moveAfter
void moveAfter(singlylinkedlistnode< valuetype > *node, singlylinkedlistnode< valuetype > *nodetomove)
singlylinkedlist::insertionSort
void insertionSort()
singlylinkedlist::~singlylinkedlist
virtual ~singlylinkedlist()
singlylinkedlistnode
Definition: singlylinkedlist.h:12
singlylinkedlist::detach
void detach(singlylinkedlistnode< valuetype > *node)
singlylinkedlistnode::compare
int32_t compare(valuetype value) const
singlylinkedlist::insertAfter
void insertAfter(singlylinkedlistnode< valuetype > *node, valuetype value)
singlylinkedlistnode::~singlylinkedlistnode
virtual ~singlylinkedlistnode()
singlylinkedlist::clear
void clear()
singlylinkedlist::getLast
singlylinkedlistnode< valuetype > * getLast()