summaryrefslogtreecommitdiff
path: root/doc/aapl/ex_avlitree.cpp
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2019-09-11 19:02:07 -0600
committerAdrian Thurston <thurston@colm.net>2019-09-11 19:02:07 -0600
commitb6c54b035748e5733f279e9bd763870f4e9267da (patch)
tree8e98185fe9690b1958d3999a3ea1c96539c01f27 /doc/aapl/ex_avlitree.cpp
parent26315e09ed7c87589a4304b98e5814d373596097 (diff)
downloadcolm-b6c54b035748e5733f279e9bd763870f4e9267da.tar.gz
moved aapl and ragel doc dirs to /doc
Diffstat (limited to 'doc/aapl/ex_avlitree.cpp')
-rw-r--r--doc/aapl/ex_avlitree.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/doc/aapl/ex_avlitree.cpp b/doc/aapl/ex_avlitree.cpp
new file mode 100644
index 00000000..40790908
--- /dev/null
+++ b/doc/aapl/ex_avlitree.cpp
@@ -0,0 +1,34 @@
+#include "avlitree.h"
+#include <iostream>
+
+struct CustomEl :
+ public AvliTreeEl<CustomEl>,
+ public CmpOrd<int>
+{
+ /* Needed for the insert(const &Key key) routine. */
+ CustomEl(int key) : key(key), data(0) { }
+
+ /* For our purposes. */
+ CustomEl(int key, const char *data) : key(key), data(data) { }
+
+ const int getKey() { return key; }
+ int key;
+ const char *data;
+};
+
+int main()
+{
+ AvliTree<CustomEl, int> tree;
+
+ /* This will make a new element for us. */
+ tree.insert( 1 );
+
+ /* Here we make the element ourselves. */
+ tree.insert( new CustomEl( 2, "CustomEl") );
+
+ for ( CustomEl *el = tree.head; el != 0; el = el->next )
+ std::cout << el->key << std::endl;
+
+ tree.empty();
+ return 0;
+}