Rudiments
linkedlist.h
1 // Copyright (c) 2003 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>
12  public:
15  linkedlistnode(valuetype value);
16 
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 
42 
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 
133  bool removeAll(valuetype value);
134 
142  bool remove(linkedlistnode<valuetype> *node);
143 
145  uint64_t getLength() const;
146 
148  linkedlistnode<valuetype> *getFirst();
149 
151  linkedlistnode<valuetype> *getLast();
152 
158 
164 
167  linkedlistnode<valuetype> *find(valuetype value);
168 
173  *find(linkedlistnode<valuetype> *startnode,
174  valuetype value);
175 
179  void insertionSort();
180 
185  void heapSort();
186 
190  void clear();
191 
193  void print() const;
194 
197  void print(uint64_t count) const;
198 
199  #include <rudiments/private/linkedlist.h>
200 };
201 
202 #include <rudiments/private/linkedlistinlines.h>
203 
204 #endif
void setValue(valuetype value)
Definition: linkedlist.h:60
valuetype getValue() const
linkedlistnode(valuetype value)
linkedlistnode< valuetype > * getPrevious()
Definition: linkedlist.h:11
int32_t compare(valuetype value) const
void print() const
linkedlistnode< valuetype > * getNext()