Rudiments: /home/dmuse/src/rudiments/include/rudiments/avltree.h Source File

Rudiments

- Main Page
- Classes

avltree.h
1 // Copyright (c) 2016 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
113 bool removeAll(valuetype value);
114
122 bool remove(avltreenode<valuetype> *node);
123
125 uint64_t getLength() const;
126
128 avltreenode<valuetype> *getTop();
129
132 avltreenode<valuetype> *getFirst();
133
136 avltreenode<valuetype> *getLast();
137
141 avltreenode<valuetype> *getPrevious(
142 avltreenode<valuetype> *node);
143
147 avltreenode<valuetype> *getNext(
148 avltreenode<valuetype> *node);
149
152 avltreenode<valuetype> *find(valuetype value);
153
157 avltreenode<valuetype>
158 *find(avltreenode<valuetype> *startnode,
159 valuetype value);
160
164 void clear();
165
167 void print() const;
168
169 #include <rudiments/private/avltree.h>
170 };
171
172 #include <rudiments/private/avltreeinlines.h>
173
174 #endif
avltreenode::print
void print() const
avltreenode::getNext
avltreenode< valuetype > * getNext()
avltree
Definition: avltree.h:77
avltreenode::getLeftChild
avltreenode< valuetype > * getLeftChild()
avltreenode::getValue
valuetype getValue() const
avltreenode::getLeftHeight
uint8_t getLeftHeight()
avltreenode::getPrevious
avltreenode< valuetype > * getPrevious()
avltreenode::getParent
avltreenode< valuetype > * getParent()
avltreenode::getRightChild
avltreenode< valuetype > * getRightChild()
avltreenode::avltreenode
avltreenode(valuetype value)
avltreenode::~avltreenode
~avltreenode()
avltreenode
Definition: avltree.h:11
avltreenode::compare
int32_t compare(valuetype value) const
avltreenode::getRightHeight
uint8_t getRightHeight()