some work (do not compile)
[svn/Cll1h/.git] / demos / trees.c
CommitLineData
436ac5fb 1#include "cll1.h"
2
3def_mem(Leaf)
4{
5 int value;
6 array(Leaf);
7};
8
9program
10{
11 Leaf leaf,root=NULL;
93583418 12 int newkey;
436ac5fb 13
93583418 14 for_ints(newkey, 8,1,-2,745,-32,-64,27,4 ) printf(" [%d]",i)
436ac5fb 15 {
16 leaf=get_mem(Leaf);
17
18 //init
19 leaf->__next=NULL;
20 leaf->__seek=NULL;
93583418 21 leaf->__key=newkey;
436ac5fb 22
23 //grow tree
436ac5fb 24 {
a68153bf 25 void *prev = NULL, *newleaf = leaf;
14e7e05a 26
27 //find where to store
a68153bf 28 for(leaf=root; leaf && leaf->__key <= newkey ; leaf=leaf->__next)
29 {
30 prev = leaf;
31 if(leaf->__seek && leaf->__seek->key <= newkey) leaf=leaf->__seek;
32 }
33
14e7e05a 34 //store new node
a68153bf 35 if(prev)
36 {
37
38 }
39 else
40 {
41
42 }
14e7e05a 43
44 //reindex B+ tree
45 for(leaf=root; leaf->__next ; leaf=leaf->__next)
46 {
47 if (leaf->__seek)
48 {
49 if (leaf->__key <= newkey)
50 leaf->__seek=leaf->__seek->__next;
51 }
52 else
53 leaf->__seek=leaf->__next->__seek;
54 }
a68153bf 55 }
cda3141a 56 }
436ac5fb 57}
This page took 0.135826 seconds and 4 git commands to generate.