From a4ef278cd8893f40007b6707d1c291a1c677713c Mon Sep 17 00:00:00 2001 From: bjeanlou Date: Thu, 28 Mar 2019 11:36:59 +0100 Subject: [PATCH] init withHash --- Slist.c | 46 ---------------------------------------------- Slist.h | 24 ------------------------ tree.c | 15 --------------- tree.h | 35 ----------------------------------- treeh.c | 2 ++ treeh.h | 31 +++++++++++++++++++++++++++++++ 6 files changed, 33 insertions(+), 120 deletions(-) delete mode 100644 Slist.c delete mode 100644 Slist.h delete mode 100644 tree.c delete mode 100644 tree.h create mode 100644 treeh.c create mode 100644 treeh.h diff --git a/Slist.c b/Slist.c deleted file mode 100644 index f2d58ed..0000000 --- a/Slist.c +++ /dev/null @@ -1,46 +0,0 @@ -#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 deleted file mode 100644 index 6467490..0000000 --- a/Slist.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef SLIST_H -#define SLIST_H - -#include "tree.h" - -typedef - struct cell{ - node* letter; - cell* next;} -//defs - cell, *List; - - -//function -List* make_empty_List(); -int is_empty(List); -int isIn_list(List,char); -void addAlpha(List*,char); -void addHead(List*,char); -void addNext(List*,char); - - - -#endif //SLIST_H diff --git a/tree.c b/tree.c deleted file mode 100644 index 456cc83..0000000 --- a/tree.c +++ /dev/null @@ -1,15 +0,0 @@ -#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 deleted file mode 100644 index ecb7c53..0000000 --- a/tree.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef TREE_H -#define TREE_H - -#include -#include -#include -#include "Slist.h" - -typedef - struct node{ - char val; - cell* next;} -//defs - node, *tree; - - -//functions -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*); -//char*? values(tree); -void print_all(tree); -int isIn_tree(tree,char); -int strIsIn_tree(tree,string); - - -/* -words end with '\0' and -*/ - -#endif //TREE_H diff --git a/treeh.c b/treeh.c new file mode 100644 index 0000000..781f47a --- /dev/null +++ b/treeh.c @@ -0,0 +1,2 @@ +#include "treeh.h" + diff --git a/treeh.h b/treeh.h new file mode 100644 index 0000000..45d34ba --- /dev/null +++ b/treeh.h @@ -0,0 +1,31 @@ +#ifndef TREEH_H +#define TREEH_H + +#include +#include +#include + +#define NBCHAR 27 //a-z + ' + + +typedef +struct node{ + char letter; + char isEnd; + node* next[NBCHAR] +} *ptNode,*tree; + +tree make_empty_tree(); + +void addto_tree(tree,char*,int); +void loadfrom_file(tree,FILE*); +void loadfrom_keyboard(tree); + +char is_empty(tree); +char is_end(tree); + +int hash(char); + + + +#endif //TREEH_H -- libgit2 0.21.2