Rudiments

avltree.h
1 // Copyright (c) 1999-2018 David Muse
2 // See the COPYING file for more information.
3
4 #ifndef RUDIMENTS_AVLTREE_H
5 #define RUDIMENTS_AVLTREE_H
6
7 #include <rudiments/private/avltreeincludes.h>
8
10 template <class valuetype>
11 class avltreenode {
12 public:
15 avltreenode(valuetype value);
16
20 ~avltreenode();
21
23 valuetype getValue() const;
24
28 int32_t compare(valuetype value) const;
29
34 int32_t compare(avltreenode<valuetype> *peer) const;
35
38 avltreenode<valuetype> *getParent();
39
42 avltreenode<valuetype> *getLeftChild();
43
46 avltreenode<valuetype> *getRightChild();
47
49 uint8_t getLeftHeight();
50
52 uint8_t getRightHeight();
53
57 avltreenode<valuetype> *getPrevious();
58
62 avltreenode<valuetype> *getNext();
63
65 void print() const;
66
67 #include <rudiments/private/avltreenode.h>
68 };
69
76 template < class valuetype >
77 class avltree {
78 public:
80 avltree();
81
85 ~avltree();
86
89 void insert(valuetype value);
90
93 void insert(avltreenode<valuetype> *node);
94
96 avltreenode<valuetype>
97 *detach(avltreenode<valuetype> *node);
98
105 bool remove(valuetype value);
106
114 bool removeAndDelete(valuetype value);
115
124 bool removeAndArrayDelete(valuetype value);
125
132 bool removeAll(valuetype value);
133
141 bool removeAllAndDelete(valuetype value);
142
151 bool removeAllAndArrayDelete(valuetype value);
152
160 bool remove(avltreenode<valuetype> *node);
161
170 bool removeAndDelete(avltreenode<valuetype> *node);
171
181 bool removeAndArrayDelete(avltreenode<valuetype> *node);
182
184 uint64_t getLength() const;
185
187 avltreenode<valuetype> *getTop();
188
191 avltreenode<valuetype> *getFirst();
192
195 avltreenode<valuetype> *getLast();
196
200 avltreenode<valuetype> *getPrevious(
201 avltreenode<valuetype> *node);
202
206 avltreenode<valuetype> *getNext(
207 avltreenode<valuetype> *node);
208
211 avltreenode<valuetype> *find(valuetype value);
212
216 avltreenode<valuetype>
217 *find(avltreenode<valuetype> *startnode,
218 valuetype value);
219
223 void clear();
224
227 void clearAndDelete();
228
232 void clearAndArrayDelete();
233
235 void print() const;
236
237 #include <rudiments/private/avltree.h>
238 };
239
240 #include <rudiments/private/avltreeinlines.h>
241
242 #endif
avltree
Definition: avltree.h:77
avltree::getTop
avltreenode< valuetype > * getTop()
avltree::insert
void insert(avltreenode< valuetype > *node)
avltree::getLast
avltreenode< valuetype > * getLast()
avltree::removeAndArrayDelete
bool removeAndArrayDelete(valuetype value)
avltree::removeAndDelete
bool removeAndDelete(valuetype value)
avltree::clearAndArrayDelete
void clearAndArrayDelete()
avltree::clearAndDelete
void clearAndDelete()
avltree::remove
bool remove(valuetype value)
avltree::removeAndArrayDelete
bool removeAndArrayDelete(avltreenode< valuetype > *node)
avltree::getPrevious
avltreenode< valuetype > * getPrevious(avltreenode< valuetype > *node)
avltree::insert
void insert(valuetype value)
avltree::removeAndDelete
bool removeAndDelete(avltreenode< valuetype > *node)
avltree::print
void print() const
avltree::detach
avltreenode< valuetype > * detach(avltreenode< valuetype > *node)
avltree::removeAllAndArrayDelete
bool removeAllAndArrayDelete(valuetype value)
avltree::removeAll
bool removeAll(valuetype value)
avltree::~avltree
~avltree()
avltree::remove
bool remove(avltreenode< valuetype > *node)
avltree::getNext
avltreenode< valuetype > * getNext(avltreenode< valuetype > *node)
avltree::avltree
avltree()
avltree::find
avltreenode< valuetype > * find(valuetype value)
avltree::getFirst
avltreenode< valuetype > * getFirst()
avltree::getLength
uint64_t getLength() const
avltree::removeAllAndDelete
bool removeAllAndDelete(valuetype value)
avltree::clear
void clear()
avltree::find
avltreenode< valuetype > * find(avltreenode< valuetype > *startnode, valuetype value)
avltreenode
Definition: avltree.h:11
avltreenode::print
void print() const
avltreenode::~avltreenode
~avltreenode()
avltreenode::compare
int32_t compare(avltreenode< valuetype > *peer) const
avltreenode::getParent
avltreenode< valuetype > * getParent()
avltreenode::getValue
valuetype getValue() const
avltreenode::avltreenode
avltreenode(valuetype value)
avltreenode::getPrevious
avltreenode< valuetype > * getPrevious()
avltreenode::getNext
avltreenode< valuetype > * getNext()
avltreenode::getRightChild
avltreenode< valuetype > * getRightChild()
avltreenode::getLeftHeight
uint8_t getLeftHeight()
avltreenode::getLeftChild
avltreenode< valuetype > * getLeftChild()
avltreenode::getRightHeight
uint8_t getRightHeight()
avltreenode::compare
int32_t compare(valuetype value) const