GRASS GIS 8 Programmer's Manual 8.4.1(2025)-45ca3179ab
Loading...
Searching...
No Matches
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 if (B->N <= 0)
10 return 0;
11
12 q = 1;
13 while (q > 0) {
14 dir = (*B->cmp)(B->node[q].key, key);
15 if (dir == 0) {
16 *data = B->node[q].data;
17 return 1;
18 }
19 if (dir > 0)
20 q = B->node[q].left; /* go left */
21 else
22 q = B->node[q].right; /* go right */
23 }
24
25 return 0;
26}
int btree_find(const BTREE *B, const void *key, void **data)
Definition btree/find.c:4