Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libodelta/suftree.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1989-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Phong Vo <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
#ifndef _SUFTREE_H
22
#define _SUFTREE_H
23
24
#include <ast.h>
25
26
/* the type of list elements we play with */
27
typedef char Element;
28
29
/* for suffix trees, a tree node looks like this */
30
typedef struct _ts_
31
{
32
Element *_label; /* substring labeling the edge */
33
long int _length; /* the length of the string */
34
struct _ts_ *_child; /* list of children */
35
struct _ts_ *_sibling; /* link for the child list */
36
union
37
{ /* these two fields are mutual exclusive */
38
struct _ts_ *_link; /* sub-link */
39
Element *_suffix; /* suffix */
40
} _uls_;
41
} Suftree;
42
43
/* short hand for various fields in a tree node */
44
#define LABEL(n) ((n)->_label)
45
#define LENGTH(n) ((n)->_length)
46
#define CHILD(n) ((n)->_child)
47
#define SIBLING(n) ((n)->_sibling)
48
#define LINK(n) ((n)->_uls_._link)
49
#define SUFFIX(n) ((n)->_uls_._suffix)
50
51
/* the following definitions are not to be seen by users */
52
#ifdef _IN_SUF_TREE
53
#ifdef DEBUG
54
#define ASSERT(p) if(!(p)) abort();
55
#else
56
#define ASSERT(p)
57
#endif /*DEBUG*/
58
59
#ifndef NULL
60
#define NULL (0L)
61
#endif /*NULL*/
62
63
#define ALLOCSIZE 256 /* amount of nodes to allocate each time */
64
#define NEXT(n) ((n)->_sibling)
65
66
#endif /*_IN_SUF_TREE*/
67
68
extern Suftree* bldsuftree(Element*, long);
69
extern void delsuftree(Suftree*);
70
extern long mtchsuftree(Suftree*, Element*, long, Element**);
71
72
#endif
73
74