trees More...
Go to the source code of this file.
Functions | |
long | intcmp (long a, long b) |
intcmp More... | |
long | is_int (char **s, long *len, long *sgn) |
is_int More... | |
long | featcmp (char *str1, char *str2) |
featcmp More... | |
char * | heap_ncopy_string (char *s, int n) |
heap_ncopy_string More... | |
char * | heap_copy_string (char *s) |
heap_copy_string More... | |
char * | stack_copy_string (char *s) |
stack_copy_string More... | |
ptr_node | general_insert (long comp, char *keystr, ptr_node *tree, GENERIC info, long heapflag, long copystr, long bkflag) |
ptr_node general_insert More... | |
void | heap_insert_copystr (char *keystr, ptr_node *tree, GENERIC info) |
heap_insert_copystr More... | |
void | stack_insert_copystr (char *keystr, ptr_node *tree, GENERIC info) |
stack_insert_copystr More... | |
ptr_node | heap_insert (long comp, char *keystr, ptr_node *tree, GENERIC info) |
heap_insert More... | |
ptr_node | stack_insert (long comp, char *keystr, ptr_node *tree, GENERIC info) |
stack_insert More... | |
ptr_node | bk_stack_insert (long comp, char *keystr, ptr_node *tree, GENERIC info) |
bk_stack_insert More... | |
ptr_node | bk2_stack_insert (long comp, char *keystr, ptr_node *tree, GENERIC info) |
bk2_stack_insert More... | |
ptr_node | find (long comp, char *keystr, ptr_node tree) |
find More... | |
ptr_node | find_data (GENERIC p, ptr_node t) |
find_data More... | |
void | delete_attr (char *s, ptr_node *n) |
delete_attr More... | |
trees
Definition in file trees.c.
bk2_stack_insert
comp | - long comp |
keystr | - char *keystr |
tree | - ptr_node *tree |
info | - GENERIC info |
BK2_STACK_INSERT(comp,keystr,tree,info) Insert the pointer INFO under the reference string KEYSTR of length len in the binary tree TREE. Return the pointer to the permanent storage place of KEY. This is used by C_APPLY_LABEL Always trail the change.
Definition at line 377 of file trees.c.
References FALSE, general_insert(), and STACK.
bk_stack_insert
comp | - long comp |
keystr | - char *keystr |
tree | - ptr_node *tree |
info | - GENERIC info |
BK_STACK_INSERT(comp,keystr,tree,info) Insert the pointer INFO under the reference string KEYSTR of length len in the binary tree TREE. Return the pointer to the permanent storage place of KEY. This is used by C_APPLY_LABEL Trail the change with a trail check.
Definition at line 357 of file trees.c.
References FALSE, general_insert(), and STACK.
void delete_attr | ( | char * | s, |
ptr_node * | n | ||
) |
delete_attr
s | - char *s |
n | - ptr_node *n |
DELETE_ATTR(key,tree) Remove the node addressed by KEY from TREE.
Definition at line 522 of file trees.c.
References wl_node::data, featcmp(), FEATCMP, heap_insert(), wl_node::key, wl_node::left, and wl_node::right.
long featcmp | ( | char * | str1, |
char * | str2 | ||
) |
featcmp
str1 | - char *str1 |
str2 | - char *str2 |
FEATCMP(s1,s2) Compares two strings which represent features, for use in FIND or INSERT. This differs from strcmp for those strings that represent integers. These are compared as integers. In addition, all integers are considered to be less than all strings that do not represent integers.
Definition at line 106 of file trees.c.
References is_int().
find
comp | - long comp |
keystr | - char *keystr |
tree | - ptr_node tree |
FIND(comp,keystr,tree) Return the NODE address corresponding to key KEYSTR in TREE using function COMP to compare keys.
Definition at line 394 of file trees.c.
References Errorline(), FALSE, featcmp(), FEATCMP, intcmp(), INTCMP, wl_node::left, NULL, wl_node::right, STRCMP, and TRUE.
find_data
p | - GENERIC p |
t | - ptr_node t |
FIND_DATA(p,t) Return the node containing the data P in tree T. This is a linear search and can be used to find the key to some data if it is unkown. Return NULL if no key corresponds to data P.
Definition at line 452 of file trees.c.
References wl_node::data, wl_node::left, NULL, and wl_node::right.
ptr_node general_insert | ( | long | comp, |
char * | keystr, | ||
ptr_node * | tree, | ||
GENERIC | info, | ||
long | heapflag, | ||
long | copystr, | ||
long | bkflag | ||
) |
ptr_node general_insert
comp | - long comp |
keystr | - char *keystr |
tree | - ptr_node *tree |
info | - GENERIC info |
heapflag | - long heapflag |
copystr | - long copystr |
bkflag | - long bkflag |
GENERAL_INSERT(comp,keystr,tree,info,heapflag,copystr,bkflag) General tree insertion routine. comp = comparison routine for insertion. keystr = the insertion key. tree = the tree to insert in. info = the information to insert. heapflag = HEAP or STACK for heap or stack allocation of insertion node. copystr = TRUE iff copy the keystr to the heap on insertion. bkflag = 1 iff the insertion is backtrackable (trailed with trail check). 2 iff the insertion must always be trailed. Returns a pointer to the node containing the pair (keystr,info).
Here KEYSTR can be either a pointer to a string, an integer, or a feature. COMP is the function to call to compare 2 keys so it has three possible values: COMP==strcmp(), COMP==intcmp(), or COMP==featcmp(). COMP(a,b) should return n where: n=0 if a=b; n>0 if a>b; n<0 if a<b.
Definition at line 224 of file trees.c.
References Errorline(), FALSE, featcmp(), FEATCMP, HEAP, HEAP_ALLOC, heap_copy_string(), int_ptr, intcmp(), INTCMP, wl_node::key, NULL, push_ptr_value(), push_ptr_value_global(), STACK_ALLOC, STRCMP, and TRUE.
char* heap_copy_string | ( | char * | s | ) |
heap_copy_string
s | - char *s |
HEAP_COPY_STRING(string) Make a copy of the string in the heap, and return a pointer to that. Exceptions: "1" and "2" are unique (and in the heap).
Definition at line 172 of file trees.c.
References heap_ncopy_string().
heap_insert
comp | - long comp |
keystr | - char *keystr |
tree | - ptr_node *tree |
info | - GENERIC info |
HEAP_INSERT(comp,keystr,tree,info) Insert the pointer INFO under the reference KEYSTR in the binary tree TREE stored in the heap. Return the pointer to the node of KEYSTR.
Definition at line 320 of file trees.c.
References FALSE, general_insert(), and HEAP.
heap_insert_copystr
keystr | - char *keystr |
tree | - ptr_node *tree |
info | - GENERIC info |
HEAP_INSERT_COPYSTR(keystr,tree,info) Insert the pointer INFO under the reference string KEYSTR (which is a feature name) in the binary tree TREE. KEYSTR is copied to the heap. A potential additional node allocated to TREE is put on the heap.
Definition at line 284 of file trees.c.
References FEATCMP, general_insert(), HEAP, and TRUE.
char* heap_ncopy_string | ( | char * | s, |
int | n | ||
) |
heap_ncopy_string
s | - char *s |
n | - int n |
HEAP_NCOPY_STRING(string,length) Make a copy of the string in the heap, and return a pointer to that. Exceptions: "1" and "2" are unique (and in the heap).
Definition at line 150 of file trees.c.
References heap_alloc(), one, and two.
long intcmp | ( | long | a, |
long | b | ||
) |
long is_int | ( | char ** | s, |
long * | len, | ||
long * | sgn | ||
) |
char* stack_copy_string | ( | char * | s | ) |
stack_copy_string
s | - char *s |
STACK_COPY_STRING(string) Make a copy of the string in the stack, and return a pointer to that. Exceptions: "1" and "2" are unique (and in the heap).
Definition at line 184 of file trees.c.
References one, stack_alloc(), and two.
stack_insert
comp | - long comp |
keystr | - char *keystr |
tree | - ptr_node *tree |
info | - GENERIC info |
STACK_INSERT(comp,keystr,tree,info) Exactly the same as heap_insert, only the new node is in the stack.
Definition at line 337 of file trees.c.
References FALSE, general_insert(), and STACK.
stack_insert_copystr
keystr | - char *keystr |
tree | - ptr_node *tree |
info | - GENERIC info |
STACK_INSERT_COPYSTR(keystr,tree,info) Insert the pointer INFO under the reference string KEYSTR (which is a feature name) in the binary tree TREE. KEYSTR is copied to the heap. A potential additional node allocated to TREE is put on the stack.
Definition at line 301 of file trees.c.
References FEATCMP, general_insert(), STACK, and TRUE.