GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-d6dec75dd4
btree/next.c
Go to the documentation of this file.
1
#include <
grass/btree.h
>
2
3
int
btree_next
(
BTREE
*B,
void
**key,
void
**data)
4
{
5
int
q;
6
7
if
(B->
N
<= 0)
8
return
0;
9
10
/* if rewound, start at root and go all the way to the left */
11
if
(B->
cur
== 0)
12
B->
cur
= 1;
13
14
/* go to the right */
15
else
16
B->
cur
= B->
node
[B->
cur
].
right
;
17
18
if
(B->
cur
== 0)
/* no more */
19
return
0;
20
21
if
(B->
cur
< 0)
/* thread. stop here */
22
B->
cur
= -(B->
cur
);
23
else
/* go all the way left */
24
while
((q = B->
node
[B->
cur
].
left
))
25
B->
cur
= q;
26
27
*key = B->
node
[B->
cur
].
key
;
28
*data = B->
node
[B->
cur
].
data
;
29
30
return
1;
31
}
btree_next
int btree_next(BTREE *B, void **key, void **data)
Definition:
btree/next.c:3
btree.h
BTREE_NODE::left
int left
Definition:
btree.h:7
BTREE_NODE::right
int right
Definition:
btree.h:8
BTREE_NODE::key
void * key
Definition:
btree.h:5
BTREE_NODE::data
void * data
Definition:
btree.h:6
BTREE
Definition:
btree.h:11
BTREE::N
int N
Definition:
btree.h:14
BTREE::cur
int cur
Definition:
btree.h:16
BTREE::node
BTREE_NODE * node
Definition:
btree.h:12
lib
btree
next.c
Generated on Sun Dec 22 2024 07:38:17 for GRASS GIS 8 Programmer's Manual by
1.9.1