Merge branch 'catalan' of github.com:Softcatala/git-po
[alt-git.git] / reftable / tree.h
blobfbdd002e23afcf61054b77cb2053e4d298e941bb
1 /*
2 Copyright 2020 Google LLC
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file or at
6 https://developers.google.com/open-source/licenses/bsd
7 */
9 #ifndef TREE_H
10 #define TREE_H
12 /* tree_node is a generic binary search tree. */
13 struct tree_node {
14 void *key;
15 struct tree_node *left, *right;
18 /* looks for `key` in `rootp` using `compare` as comparison function. If insert
19 * is set, insert the key if it's not found. Else, return NULL.
21 struct tree_node *tree_search(void *key, struct tree_node **rootp,
22 int (*compare)(const void *, const void *),
23 int insert);
25 /* performs an infix walk of the tree. */
26 void infix_walk(struct tree_node *t, void (*action)(void *arg, void *key),
27 void *arg);
30 * deallocates the tree nodes recursively. Keys should be deallocated separately
31 * by walking over the tree. */
32 void tree_free(struct tree_node *t);
34 #endif