Rudiments

linkedlist.h
1 // Copyright (c) 1999-2018 David Muse
2 // See the COPYING file for more information.
3
4 #ifndef RUDIMENTS_LINKEDLIST_H
5 #define RUDIMENTS_LINKEDLIST_H
6
7 #include <rudiments/private/linkedlistincludes.h>
8
10 template <class valuetype>
11 class linkedlistnode {
12 public:
15 linkedlistnode(valuetype value);
16
20 ~linkedlistnode();
21
23 void setValue(valuetype value);
24
26 valuetype getValue() const;
27
31 int32_t compare(valuetype value) const;
32
37 int32_t compare(linkedlistnode<valuetype> *peer) const;
38
41 linkedlistnode<valuetype> *getPrevious();
42
45 linkedlistnode<valuetype> *getNext();
46
48 void print() const;
49
50 #include <rudiments/private/linkedlistnode.h>
51 };
52
59 template < class valuetype >
60 class linkedlist {
61 public:
63 linkedlist();
64
68 ~linkedlist();
69
72 void prepend(valuetype value);
73
76 void prepend(linkedlistnode<valuetype> *node);
77
80 void append(valuetype value);
81
84 void append(linkedlistnode<valuetype> *node);
85
88 void insertBefore(linkedlistnode<valuetype> *node,
89 valuetype value);
90
93 void insertBefore(linkedlistnode<valuetype> *node,
94 linkedlistnode<valuetype> *newnode);
95
98 void insertAfter(linkedlistnode<valuetype> *node,
99 valuetype value);
100
103 void insertAfter(linkedlistnode<valuetype> *node,
104 linkedlistnode<valuetype> *newnode);
105
108 void moveBefore(linkedlistnode<valuetype> *node,
109 linkedlistnode<valuetype> *nodetomove);
110
113 void moveAfter(linkedlistnode<valuetype> *node,
114 linkedlistnode<valuetype> *nodetomove);
115
117 void detach(linkedlistnode<valuetype> *node);
118
125 bool remove(valuetype value);
126
134 bool removeAndDelete(valuetype value);
135
144 bool removeAndArrayDelete(valuetype value);
145
152 bool removeAll(valuetype value);
153
161 bool removeAllAndDelete(valuetype value);
162
171 bool removeAllAndArrayDelete(valuetype value);
172
180 bool remove(linkedlistnode<valuetype> *node);
181
190 bool removeAndDelete(linkedlistnode<valuetype> *node);
191
201 bool removeAndArrayDelete(linkedlistnode<valuetype> *node);
202
204 uint64_t getLength() const;
205
207 linkedlistnode<valuetype> *getFirst();
208
210 linkedlistnode<valuetype> *getLast();
211
215 linkedlistnode<valuetype> *getPrevious(
216 linkedlistnode<valuetype> *node);
217
221 linkedlistnode<valuetype> *getNext(
222 linkedlistnode<valuetype> *node);
223
226 linkedlistnode<valuetype> *find(valuetype value);
227
231 linkedlistnode<valuetype>
232 *find(linkedlistnode<valuetype> *startnode,
233 valuetype value);
234
238 void insertionSort();
239
244 void heapSort();
245
249 void clear();
250
254 void clearAndDelete();
255
259 void clearAndArrayDelete();
260
262 void print() const;
263
266 void print(uint64_t count) const;
267
268 #include <rudiments/private/linkedlist.h>
269 };
270
271 #include <rudiments/private/linkedlistinlines.h>
272
273 #endif
linkedlist
Definition: linkedlist.h:60
linkedlist::insertionSort
void insertionSort()
linkedlist::removeAll
bool removeAll(valuetype value)
linkedlist::getLength
uint64_t getLength() const
linkedlist::find
linkedlistnode< valuetype > * find(linkedlistnode< valuetype > *startnode, valuetype value)
linkedlist::removeAllAndArrayDelete
bool removeAllAndArrayDelete(valuetype value)
linkedlist::moveBefore
void moveBefore(linkedlistnode< valuetype > *node, linkedlistnode< valuetype > *nodetomove)
linkedlist::remove
bool remove(linkedlistnode< valuetype > *node)
linkedlist::getPrevious
linkedlistnode< valuetype > * getPrevious(linkedlistnode< valuetype > *node)
linkedlist::moveAfter
void moveAfter(linkedlistnode< valuetype > *node, linkedlistnode< valuetype > *nodetomove)
linkedlist::clear
void clear()
linkedlist::getFirst
linkedlistnode< valuetype > * getFirst()
linkedlist::removeAndArrayDelete
bool removeAndArrayDelete(valuetype value)
linkedlist::print
void print(uint64_t count) const
linkedlist::insertAfter
void insertAfter(linkedlistnode< valuetype > *node, valuetype value)
linkedlist::getNext
linkedlistnode< valuetype > * getNext(linkedlistnode< valuetype > *node)
linkedlist::insertBefore
void insertBefore(linkedlistnode< valuetype > *node, valuetype value)
linkedlist::append
void append(valuetype value)
linkedlist::clearAndDelete
void clearAndDelete()
linkedlist::prepend
void prepend(valuetype value)
linkedlist::find
linkedlistnode< valuetype > * find(valuetype value)
linkedlist::clearAndArrayDelete
void clearAndArrayDelete()
linkedlist::detach
void detach(linkedlistnode< valuetype > *node)
linkedlist::insertBefore
void insertBefore(linkedlistnode< valuetype > *node, linkedlistnode< valuetype > *newnode)
linkedlist::print
void print() const
linkedlist::removeAndArrayDelete
bool removeAndArrayDelete(linkedlistnode< valuetype > *node)
linkedlist::insertAfter
void insertAfter(linkedlistnode< valuetype > *node, linkedlistnode< valuetype > *newnode)
linkedlist::prepend
void prepend(linkedlistnode< valuetype > *node)
linkedlist::removeAllAndDelete
bool removeAllAndDelete(valuetype value)
linkedlist::linkedlist
linkedlist()
linkedlist::~linkedlist
~linkedlist()
linkedlist::getLast
linkedlistnode< valuetype > * getLast()
linkedlist::removeAndDelete
bool removeAndDelete(linkedlistnode< valuetype > *node)
linkedlist::append
void append(linkedlistnode< valuetype > *node)
linkedlist::remove
bool remove(valuetype value)
linkedlist::removeAndDelete
bool removeAndDelete(valuetype value)
linkedlist::heapSort
void heapSort()
linkedlistnode
Definition: linkedlist.h:11
linkedlistnode::getPrevious
linkedlistnode< valuetype > * getPrevious()
linkedlistnode::print
void print() const
linkedlistnode::getValue
valuetype getValue() const
linkedlistnode::setValue
void setValue(valuetype value)
linkedlistnode::compare
int32_t compare(linkedlistnode< valuetype > *peer) const
linkedlistnode::getNext
linkedlistnode< valuetype > * getNext()
linkedlistnode::compare
int32_t compare(valuetype value) const
linkedlistnode::~linkedlistnode
~linkedlistnode()
linkedlistnode::linkedlistnode
linkedlistnode(valuetype value)