Tissue Forge C++
0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfBtree.h
1
/*******************************************************************************
2
* This file is part of mdcore.
3
* Coypright (c) 2010 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
4
* Copyright (c) 2022-2024 T.J. Sego
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published
8
* by the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*
19
******************************************************************************/
20
21
#ifndef _MDCORE_SOURCE_TFBTREE_H_
22
#define _MDCORE_SOURCE_TFBTREE_H_
23
25
#define btree_maxnodes 8
26
#define btree_minnodes 4
27
#define btree_cache 256
28
29
31
#define btree_err_ok 0
32
#define btree_err_null -1
33
#define btree_err_malloc -2
34
#define btree_err_map -3
35
36
38
#define btree_flag_freeable 1
39
#define btree_flag_leaf 2
40
41
43
#define btree_maptype int (*)(void *, void *)
44
45
46
namespace
TissueForge
{
47
48
50
extern
int
btree_err
;
51
53
struct
btree_node
{
54
55
short
int
fill;
// nr of nodes in node (2 bytes)
56
unsigned
short
int
flags;
// node flags (2 bytes)
57
void
*data[btree_maxnodes + 1];
// node content ((N+1)*4 bytes)
58
int
keys[btree_maxnodes + 1];
// node keys ((N+1)*4 bytes)
59
struct
btree_node
*nodes[btree_maxnodes + 2];
60
// node branches; ((N+2)*4 bytes)
61
62
};
63
65
struct
btree
{
66
67
struct
btree_node
*first;
// first node in tree
68
69
struct
btree_node
*cache;
// cached nodes
70
71
};
72
73
int
btree_init(
struct
btree
*b);
74
struct
btree_node
*btree_getnode(
struct
btree
*b);
75
int
btree_insert(
struct
btree
*b,
int
key,
void
*data);
76
int
btree_map(
struct
btree
*b,
int
(*func)(
void
*,
void
*),
void
*data);
77
int
btree_find(
struct
btree
*b,
int
key,
void
**res);
78
int
btree_releasenode(
struct
btree
*b,
struct
btree_node
*n);
79
int
btree_delete(
struct
btree
*b,
int
key,
void
**res);
80
81
};
82
83
#endif
// _MDCORE_SOURCE_TFBTREE_H_
TissueForge
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition
tfAngleConfig.h:26
TissueForge::btree_err
int btree_err
TissueForge::btree_node
Definition
tfBtree.h:53
TissueForge::btree
Definition
tfBtree.h:65
source
mdcore
src
tfBtree.h
Generated by
1.10.0