GRASS Programmer's Manual
6.4.2(2012)
|
00001 #include <grass/btree.h> 00002 00003 int btree_next(BTREE * B, void **key, void **data) 00004 { 00005 int q; 00006 00007 if (B->N <= 0) 00008 return 0; 00009 00010 /* if rewound, start at root and go all the way to the left */ 00011 if (B->cur == 0) 00012 B->cur = 1; 00013 00014 /* go to the right */ 00015 else 00016 B->cur = B->node[B->cur].right; 00017 00018 if (B->cur == 0) /* no more */ 00019 return 0; 00020 00021 if (B->cur < 0) /* thread. stop here */ 00022 B->cur = -(B->cur); 00023 else /* go all the way left */ 00024 while ((q = B->node[B->cur].left)) 00025 B->cur = q; 00026 00027 *key = B->node[B->cur].key; 00028 *data = B->node[B->cur].data; 00029 00030 return 1; 00031 }