/usr/include/astrometry/bt.h is in libastrometry-dev 0.67+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | /*
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
*/
#ifndef BT_H
#define BT_H
#include "astrometry/keywords.h"
#include "astrometry/an-bool.h"
/*
We distinguish between "branch" (ie, internal) nodes and "leaf" nodes
because leaf nodes can be much smaller. Since there are a lot of leaves,
the space savings can be considerable.
The data owned by a leaf node follows right after the leaf struct
itself.
*/
struct bt_leaf {
// always 1; must be the first element in the struct.
unsigned char isleaf;
// number of data elements.
short N;
// data follows implicitly.
};
typedef struct bt_leaf bt_leaf;
struct bt_branch {
// always 0; must be the first element in the struct.
unsigned char isleaf;
// AVL balance
signed char balance;
//struct bt_node* children[2];
union bt_node* children[2];
// the leftmost leaf node in this subtree.
bt_leaf* firstleaf;
// number of element in this subtree.
int N;
};
typedef struct bt_branch bt_branch;
union bt_node {
bt_leaf leaf;
bt_branch branch;
};
typedef union bt_node bt_node;
struct bt {
bt_node* root;
int datasize;
int blocksize;
int N;
};
typedef struct bt bt;
typedef int (*compare_func)(const void* v1, const void* v2);
typedef int (*compare_func_2)(const void* v1, const void* v2, void* token);
Malloc bt* bt_new(int datasize, int blocksize);
void bt_free(bt* tree);
Pure //Inline
int bt_size(bt* tree);
anbool bt_insert(bt* tree, void* data, anbool unique, compare_func compare);
anbool bt_insert2(bt* tree, void* data, anbool unique, compare_func_2 compare, void* token);
anbool bt_contains(bt* tree, void* data, compare_func compare);
anbool bt_contains2(bt* tree, void* data, compare_func_2 compare, void* token);
void* bt_access(bt* tree, int index);
void bt_print(bt* tree, void (*print_element)(void* val));
void bt_print_structure(bt* tree, void (*print_element)(void* val));
int bt_height(bt* tree);
int bt_count_leaves(bt* tree);
int bt_check(bt* tree);
#endif
|