/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1989-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Phong Vo <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20#ifndef _SUFTREE_H21#define _SUFTREE_H2223#include <ast.h>2425/* the type of list elements we play with */26typedef char Element;2728/* for suffix trees, a tree node looks like this */29typedef struct _ts_30{31Element *_label; /* substring labeling the edge */32long int _length; /* the length of the string */33struct _ts_ *_child; /* list of children */34struct _ts_ *_sibling; /* link for the child list */35union36{ /* these two fields are mutual exclusive */37struct _ts_ *_link; /* sub-link */38Element *_suffix; /* suffix */39} _uls_;40} Suftree;4142/* short hand for various fields in a tree node */43#define LABEL(n) ((n)->_label)44#define LENGTH(n) ((n)->_length)45#define CHILD(n) ((n)->_child)46#define SIBLING(n) ((n)->_sibling)47#define LINK(n) ((n)->_uls_._link)48#define SUFFIX(n) ((n)->_uls_._suffix)4950/* the following definitions are not to be seen by users */51#ifdef _IN_SUF_TREE52#ifdef DEBUG53#define ASSERT(p) if(!(p)) abort();54#else55#define ASSERT(p)56#endif /*DEBUG*/5758#ifndef NULL59#define NULL (0L)60#endif /*NULL*/6162#define ALLOCSIZE 256 /* amount of nodes to allocate each time */63#define NEXT(n) ((n)->_sibling)6465#endif /*_IN_SUF_TREE*/6667extern Suftree* bldsuftree(Element*, long);68extern void delsuftree(Suftree*);69extern long mtchsuftree(Suftree*, Element*, long, Element**);7071#endif727374