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 
20  virtual ~linkedlistnode();
21 
23  void setValue(valuetype value);
24 
26  valuetype getValue() const;
27 
31  int32_t compare(valuetype value) const;
32 
34  void setPrevious(linkedlistnode<valuetype> *previous);
35 
38 
41 
44 
46  void print() const;
47 
48  #include <rudiments/private/linkedlistnode.h>
49 };
50 
57 template < class valuetype >
58 class linkedlist {
59  public:
61  linkedlist();
62 
66  virtual ~linkedlist();
67 
70  void append(valuetype value);
71 
75 
80  bool insert(uint64_t index, valuetype value);
81 
86  bool insert(uint64_t index, linkedlistnode<valuetype> *node);
87 
91  bool removeByIndex(uint64_t index);
92 
96  bool removeByValue(valuetype value);
97 
101  bool removeAllByValue(valuetype value);
102 
107 
112  bool setValueByIndex(uint64_t index, valuetype value);
113 
118  bool getValueByIndex(uint64_t index, valuetype *value);
119 
121  uint64_t getLength() const;
122 
125 
128 
131  *getNodeByIndex(uint64_t index);
132 
136  *getNodeByValue(valuetype value);
137 
142  valuetype value);
143 
147  void clear();
148 
150  void print() const;
151 
152  #include <rudiments/private/linkedlist.h>
153 };
154 
155 
156 // ideally I'd use typdefs for these but older compilers can't handle them
157 #define stringlistnode linkedlistnode< char * >
158 #define stringlist linkedlist< char * >
159 #define conststringlistnode linkedlistnode< const char * >
160 #define conststringlist linkedlist< const char * >
161 
162 #include <rudiments/private/linkedlistinlines.h>
163 
164 #endif