summaryrefslogtreecommitdiff
path: root/aapl-repos/doc/ex_avltree.cpp
blob: b94e2798684024a7407e1a829f2498757c0f1452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "avltree.h"

struct CustomEl :
		public AvlTreeEl<CustomEl>,
		public CmpOrd<int>
{
	/* Needed only 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()
{
	AvlTree<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") );

	tree.empty();
	return 0;
}