]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/et-forest.h
alloc-pool.h (free_alloc_pool_if_empty): Prototype new function.
[thirdparty/gcc.git] / gcc / et-forest.h
CommitLineData
502b8322 1/* Et-forest data structure implementation.
5f996627 2 Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
f1cfb09f
JH
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
366ccddb 16Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
f1cfb09f 17
502b8322 18/* This package implements ET forest data structure. Each tree in
f1cfb09f
JH
19 the structure maintains a tree structure and offers logarithmic time
20 for tree operations (insertion and removal of nodes and edges) and
fbe5a4a6 21 poly-logarithmic time for nearest common ancestor.
502b8322 22
d91edf86 23 ET tree stores its structure as a sequence of symbols obtained
f1cfb09f
JH
24 by dfs(root)
25
502b8322 26 dfs (node)
f1cfb09f
JH
27 {
28 s = node;
29 for each child c of node do
30 s = concat (s, c, node);
31 return s;
32 }
502b8322 33
f1cfb09f 34 For example for tree
502b8322 35
f1cfb09f
JH
36 1
37 / | \
38 2 3 4
39 / |
40 4 5
502b8322 41
f1cfb09f 42 the sequence is 1 2 4 2 5 3 1 3 1 4 1.
502b8322 43
e0bb17a8 44 The sequence is stored in a slightly modified splay tree.
f1cfb09f
JH
45 In order to support various types of node values, a hashtable
46 is used to convert node values to the internal representation. */
47
48#ifndef _ET_TREE_H
49#define _ET_TREE_H
50
51#include <ansidecl.h>
52#include <stddef.h>
53
54#ifdef __cplusplus
55extern "C" {
56#endif /* __cplusplus */
57
d47cc544
SB
58/* The node representing the node in an et tree. */
59struct et_node
60{
61 void *data; /* The data represented by the node. */
62
63 int dfs_num_in, dfs_num_out; /* Number of the node in the dfs ordering. */
64
65 struct et_node *father; /* Father of the node. */
66 struct et_node *son; /* The first of the sons of the node. */
67 struct et_node *left;
68 struct et_node *right; /* The brothers of the node. */
69
71cc389b
KH
70 struct et_occ *rightmost_occ; /* The rightmost occurrence. */
71 struct et_occ *parent_occ; /* The occurrence of the parent node. */
d47cc544
SB
72};
73
74struct et_node *et_new_tree (void *data);
75void et_free_tree (struct et_node *);
bef87a34 76void et_free_tree_force (struct et_node *);
5a6ccafd 77void et_free_pools (void);
d47cc544
SB
78void et_set_father (struct et_node *, struct et_node *);
79void et_split (struct et_node *);
80struct et_node *et_nca (struct et_node *, struct et_node *);
81bool et_below (struct et_node *, struct et_node *);
f1cfb09f
JH
82
83#ifdef __cplusplus
84}
85#endif /* __cplusplus */
86
87#endif /* _ET_TREE_H */