Commit a4ef278cd8893f40007b6707d1c291a1c677713c

Authored by bjeanlou
1 parent 2a10535a

init withHash

Showing 6 changed files with 33 additions and 120 deletions   Show diff stats
Slist.c deleted
@@ -1,46 +0,0 @@ @@ -1,46 +0,0 @@
1 -#include "Slist.h"  
2 -  
3 -List make_empty_list(){  
4 - return NULL;  
5 -}  
6 -  
7 -int is_empty(List l){  
8 - return l==NULL;  
9 -}  
10 -int isIn_List(List l, char e){  
11 - return !is_empty(l) &&  
12 - (isIn_tree(l.letter,e) ||  
13 - isIn_list(l.next,e));  
14 -}  
15 -  
16 -  
17 -//add  
18 -void addHead(List*l,char e){  
19 - cell* tmp=malloc(sizeof(cell));  
20 - tmp->letter=make_tree(e);  
21 - tmp->next=*l;  
22 - *l=tmp;  
23 -}  
24 -void addNext(List*l,char e){  
25 - if(is_empty(*l))  
26 - addHead(l,e);  
27 - else{  
28 - cell* tmp=malloc(sizeof(cell));  
29 - tmp->letter=make_tree(e);  
30 - tmp->next=*l->next;  
31 - *l=tmp;  
32 -}  
33 -void addAlpha(List*l,char e){  
34 - if(is_empty(*l) || e<(l->letter->val)){  
35 - addHead(l,e);  
36 - return;  
37 - }  
38 - cell* crt=*l;  
39 - while(!is_empty(crt->next) && e < crt->next->letter->val)  
40 - crt=crt->next;  
41 - if(is_empty(crt->next))  
42 - addHead(&crt->next,e);  
43 -  
44 - if(e> crt->next-letter->val){  
45 -  
46 -}  
Slist.h deleted
@@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
1 -#ifndef SLIST_H  
2 -#define SLIST_H  
3 -  
4 -#include "tree.h"  
5 -  
6 -typedef  
7 - struct cell{  
8 - node* letter;  
9 - cell* next;}  
10 -//defs  
11 - cell, *List;  
12 -  
13 -  
14 -//function  
15 -List* make_empty_List();  
16 -int is_empty(List);  
17 -int isIn_list(List,char);  
18 -void addAlpha(List*,char);  
19 -void addHead(List*,char);  
20 -void addNext(List*,char);  
21 -  
22 -  
23 -  
24 -#endif //SLIST_H  
tree.c deleted
@@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
1 -#include "tree.h"  
2 -  
3 -tree make_empty_tree(){  
4 - return NULL;  
5 -}  
6 -int is_empty(tree t){  
7 - return t==NULL;  
8 -}  
9 -int is_leaf(tree t){  
10 - return is_empty(t.next);//<=>t.val=='\0'  
11 -}  
12 -int is_end(tree t){  
13 - return isIn_list(t.next,'\0');  
14 -}  
15 -  
tree.h deleted
@@ -1,35 +0,0 @@ @@ -1,35 +0,0 @@
1 -#ifndef TREE_H  
2 -#define TREE_H  
3 -  
4 -#include <stdio.h>  
5 -#include <stdlib.h>  
6 -#include <string.h>  
7 -#include "Slist.h"  
8 -  
9 -typedef  
10 - struct node{  
11 - char val;  
12 - cell* next;}  
13 -//defs  
14 - node, *tree;  
15 -  
16 -  
17 -//functions  
18 -tree make_empty_tree();  
19 -tree make_tree(char);  
20 -int is_empty(tree);  
21 -int is_leaf(tree);  
22 -int is_end(tree);  
23 -tree* cons_tree();  
24 -tree* load_tree(FILE*,tree*);  
25 -//char*? values(tree);  
26 -void print_all(tree);  
27 -int isIn_tree(tree,char);  
28 -int strIsIn_tree(tree,string);  
29 -  
30 -  
31 -/*  
32 -words end with '\0' and  
33 -*/  
34 -  
35 -#endif //TREE_H  
treeh.c 0 → 100644
@@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
  1 +#include "treeh.h"
  2 +
treeh.h 0 → 100644
@@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
  1 +#ifndef TREEH_H
  2 +#define TREEH_H
  3 +
  4 +#include <stdlib.h>
  5 +#include <stdio.h>
  6 +#include <string.h>
  7 +
  8 +#define NBCHAR 27 //a-z + '
  9 +
  10 +
  11 +typedef
  12 +struct node{
  13 + char letter;
  14 + char isEnd;
  15 + node* next[NBCHAR]
  16 +} *ptNode,*tree;
  17 +
  18 +tree make_empty_tree();
  19 +
  20 +void addto_tree(tree,char*,int);
  21 +void loadfrom_file(tree,FILE*);
  22 +void loadfrom_keyboard(tree);
  23 +
  24 +char is_empty(tree);
  25 +char is_end(tree);
  26 +
  27 +int hash(char);
  28 +
  29 +
  30 +
  31 +#endif //TREEH_H