Rudiments

singlylinkedlist.h
1 // Copyright (c) 1999-2018 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 ~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 ~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
134 bool removeAndDelete(valuetype value);
135
144 bool removeAndArrayDelete(valuetype value);
145
153 bool removeAll(valuetype value);
154
162 bool removeAllAndDelete(valuetype value);
163
172 bool removeAllAndArrayDelete(valuetype value);
173
182 bool remove(singlylinkedlistnode<valuetype> *node);
183
193 bool removeAndDelete(
194 singlylinkedlistnode<valuetype> *node);
195
206 bool removeAndArrayDelete(
207 singlylinkedlistnode<valuetype> *node);
208
210 uint64_t getLength() const;
211
213 singlylinkedlistnode<valuetype> *getFirst();
214
216 singlylinkedlistnode<valuetype> *getLast();
217
221 singlylinkedlistnode<valuetype> *getNext(
222 singlylinkedlistnode<valuetype> *node);
223
226 singlylinkedlistnode<valuetype> *find(valuetype value);
227
231 singlylinkedlistnode<valuetype>
232 *find(singlylinkedlistnode<valuetype> *startnode,
233 valuetype value);
234
238 void insertionSort();
239
244 void heapSort();
245
249 void clear();
250
254 void clearAndDelete();
255
260 void clearAndArrayDelete();
261
263 void print() const;
264
267 void print(uint64_t count) const;
268
269 #include <rudiments/private/singlylinkedlist.h>
270 };
271
272
273 #include <rudiments/private/singlylinkedlistinlines.h>
274
275 #endif
singlylinkedlist
Definition: singlylinkedlist.h:64
singlylinkedlist::getLength
uint64_t getLength() const
singlylinkedlist::insertionSort
void insertionSort()
singlylinkedlist::getFirst
singlylinkedlistnode< valuetype > * getFirst()
singlylinkedlist::detach
void detach(singlylinkedlistnode< valuetype > *node)
singlylinkedlist::remove
bool remove(singlylinkedlistnode< valuetype > *node)
singlylinkedlist::find
singlylinkedlistnode< valuetype > * find(singlylinkedlistnode< valuetype > *startnode, valuetype value)
singlylinkedlist::removeAllAndArrayDelete
bool removeAllAndArrayDelete(valuetype value)
singlylinkedlist::prepend
void prepend(valuetype value)
singlylinkedlist::singlylinkedlist
singlylinkedlist()
singlylinkedlist::removeAndArrayDelete
bool removeAndArrayDelete(valuetype value)
singlylinkedlist::moveAfter
void moveAfter(singlylinkedlistnode< valuetype > *node, singlylinkedlistnode< valuetype > *nodetomove)
singlylinkedlist::getLast
singlylinkedlistnode< valuetype > * getLast()
singlylinkedlist::append
void append(valuetype value)
singlylinkedlist::insertAfter
void insertAfter(singlylinkedlistnode< valuetype > *node, valuetype value)
singlylinkedlist::find
singlylinkedlistnode< valuetype > * find(valuetype value)
singlylinkedlist::append
void append(singlylinkedlistnode< valuetype > *node)
singlylinkedlist::clear
void clear()
singlylinkedlist::removeAndArrayDelete
bool removeAndArrayDelete(singlylinkedlistnode< valuetype > *node)
singlylinkedlist::print
void print() const
singlylinkedlist::print
void print(uint64_t count) const
singlylinkedlist::heapSort
void heapSort()
singlylinkedlist::clearAndArrayDelete
void clearAndArrayDelete()
singlylinkedlist::removeAll
bool removeAll(valuetype value)
singlylinkedlist::prepend
void prepend(singlylinkedlistnode< valuetype > *node)
singlylinkedlist::insertAfter
void insertAfter(singlylinkedlistnode< valuetype > *node, singlylinkedlistnode< valuetype > *newnode)
singlylinkedlist::removeAndDelete
bool removeAndDelete(valuetype value)
singlylinkedlist::remove
bool remove(valuetype value)
singlylinkedlist::clearAndDelete
void clearAndDelete()
singlylinkedlist::~singlylinkedlist
~singlylinkedlist()
singlylinkedlist::removeAndDelete
bool removeAndDelete(singlylinkedlistnode< valuetype > *node)
singlylinkedlist::removeAllAndDelete
bool removeAllAndDelete(valuetype value)
singlylinkedlist::getNext
singlylinkedlistnode< valuetype > * getNext(singlylinkedlistnode< valuetype > *node)
singlylinkedlistnode
Definition: singlylinkedlist.h:12
singlylinkedlistnode::compare
int32_t compare(singlylinkedlistnode< valuetype > *peer) const
singlylinkedlistnode::getValue
valuetype getValue() const
singlylinkedlistnode::compare
int32_t compare(valuetype value) const
singlylinkedlistnode::singlylinkedlistnode
singlylinkedlistnode(valuetype value)
singlylinkedlistnode::print
void print() const
singlylinkedlistnode::getNext
singlylinkedlistnode< valuetype > * getNext()
singlylinkedlistnode::setValue
void setValue(valuetype value)
singlylinkedlistnode::~singlylinkedlistnode
~singlylinkedlistnode()