GRASS GIS 8 Programmer's Manual 8.2.1(2023)-exported
btree/find.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <grass/btree.h>
3
4int btree_find(const BTREE * B, const void *key, void **data)
5{
6 int q;
7 int dir;
8
9
10 if (B->N <= 0)
11 return 0;
12
13 q = 1;
14 while (q > 0) {
15 dir = (*B->cmp) (B->node[q].key, key);
16 if (dir == 0) {
17 *data = B->node[q].data;
18 return 1;
19 }
20 if (dir > 0)
21 q = B->node[q].left; /* go left */
22 else
23 q = B->node[q].right; /* go right */
24 }
25
26 return 0;
27}
int btree_find(const BTREE *B, const void *key, void **data)
Definition: btree/find.c:4