|
|
1.1 ! root 1: /* the type of list elements we play with */ ! 2: typedef char Element; ! 3: ! 4: /* for suffix trees, a tree node looks like this */ ! 5: typedef struct _ts_ ! 6: { ! 7: Element *_label; /* substring labeling the edge */ ! 8: long int _length; /* the length of the string */ ! 9: struct _ts_ *_child; /* list of children */ ! 10: struct _ts_ *_sibling; /* link for the child list */ ! 11: union ! 12: { /* these two fields are mutual exclusive */ ! 13: struct _ts_ *_link; /* sub-link */ ! 14: Element *_suffix; /* suffix */ ! 15: } _uls_; ! 16: } Suftree; ! 17: ! 18: /* short hand for various fields in a tree node */ ! 19: #define LABEL(n) ((n)->_label) ! 20: #define LENGTH(n) ((n)->_length) ! 21: #define CHILD(n) ((n)->_child) ! 22: #define SIBLING(n) ((n)->_sibling) ! 23: #define LINK(n) ((n)->_uls_._link) ! 24: #define SUFFIX(n) ((n)->_uls_._suffix) ! 25: ! 26: extern Suftree *bldsuftree(); ! 27: extern long mtchsuftree(); ! 28: ! 29: ! 30: /* the following definitions are not to be seen by users */ ! 31: #ifdef _IN_SUF_TREE ! 32: #ifdef DEBUG ! 33: #define ASSERT(p) if(!(p)) abort(); ! 34: #else ! 35: #define ASSERT(p) ! 36: #endif /*DEBUG*/ ! 37: ! 38: #ifndef NULL ! 39: #define NULL (0L) ! 40: #endif /*NULL*/ ! 41: ! 42: #ifndef NIL ! 43: #define NIL(type) ((type*)NULL) ! 44: #endif /*NIL*/ ! 45: ! 46: #define ALLOCSIZE 256 /* amount of nodes to allocate each time */ ! 47: #define NEXT(n) ((n)->_sibling) ! 48: ! 49: #endif /*_IN_SUF_TREE*/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.