diff --git a/Slist.c b/Slist.c index f5571c8..f2d58ed 100644 --- a/Slist.c +++ b/Slist.c @@ -1 +1,46 @@ #include "Slist.h" + +List make_empty_list(){ + return NULL; +} + +int is_empty(List l){ + return l==NULL; +} +int isIn_List(List l, char e){ + return !is_empty(l) && + (isIn_tree(l.letter,e) || + isIn_list(l.next,e)); +} + + +//add +void addHead(List*l,char e){ + cell* tmp=malloc(sizeof(cell)); + tmp->letter=make_tree(e); + tmp->next=*l; + *l=tmp; +} +void addNext(List*l,char e){ + if(is_empty(*l)) + addHead(l,e); + else{ + cell* tmp=malloc(sizeof(cell)); + tmp->letter=make_tree(e); + tmp->next=*l->next; + *l=tmp; +} +void addAlpha(List*l,char e){ + if(is_empty(*l) || e<(l->letter->val)){ + addHead(l,e); + return; + } + cell* crt=*l; + while(!is_empty(crt->next) && e < crt->next->letter->val) + crt=crt->next; + if(is_empty(crt->next)) + addHead(&crt->next,e); + + if(e> crt->next-letter->val){ + +} diff --git a/Slist.h b/Slist.h index 6f15421..6467490 100644 --- a/Slist.h +++ b/Slist.h @@ -14,9 +14,10 @@ typedef //function List* make_empty_List(); int is_empty(List); -tree* head(List); -List* Queue(List); - +int isIn_list(List,char); +void addAlpha(List*,char); +void addHead(List*,char); +void addNext(List*,char); diff --git a/tree.c b/tree.c index bc9531c..456cc83 100644 --- a/tree.c +++ b/tree.c @@ -1 +1,15 @@ #include "tree.h" + +tree make_empty_tree(){ + return NULL; +} +int is_empty(tree t){ + return t==NULL; +} +int is_leaf(tree t){ + return is_empty(t.next);//<=>t.val=='\0' +} +int is_end(tree t){ + return isIn_list(t.next,'\0'); +} + diff --git a/tree.h b/tree.h index f3c4236..ecb7c53 100644 --- a/tree.h +++ b/tree.h @@ -15,17 +15,21 @@ typedef //functions -tree* make_empty_tree(); +tree make_empty_tree(); +tree make_tree(char); +int is_empty(tree); +int is_leaf(tree); +int is_end(tree); tree* cons_tree(); tree* load_tree(FILE*,tree*); -int is_empty(tree); -char value(tree); //char*? values(tree); void print_all(tree); -int isIn(tree,string); - - +int isIn_tree(tree,char); +int strIsIn_tree(tree,string); +/* +words end with '\0' and +*/ #endif //TREE_H -- libgit2 0.21.2