Commit 0bc3d1ad2b177abc71139e476a50534eb96ef4fe
1 parent
c6a94513
dico created
Showing
3 changed files
with
43 additions
and
4 deletions
Show diff stats
@@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
1 | +#include "dico.h" | ||
2 | + | ||
3 | +void make_empty_dico(dico d){ | ||
4 | + for(int i=0;i<NB1CHAR;i++) | ||
5 | + d[i]=NULL; | ||
6 | +} | ||
7 | +void delete_dico(dico_d){ | ||
8 | + for(int i=0;i<NB1CHAR;i++) | ||
9 | + delete_tree(d[i]); | ||
10 | +} | ||
11 | + | ||
12 | + | ||
13 | +int hash2(char c){ | ||
14 | + //needs to check isalpha==true | ||
15 | + if(c<='Z') | ||
16 | + return c-'A'; | ||
17 | + return c-'a'+26; | ||
18 | +} | ||
19 | +bool addto_dico(dico,string){} |
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +#ifndef DICO_H | ||
2 | +#define DICO_H | ||
3 | + | ||
4 | +#include "treeh.h" | ||
5 | + | ||
6 | +#define NB1CHAR 52 // A-Z + a-z | ||
7 | + | ||
8 | +typedef tree dico[NB1CHAR]; | ||
9 | + | ||
10 | +void make_empty_dico(dico); | ||
11 | +void delete_dico(dico); | ||
12 | +int hash2(char);//needs to check isalpha==true | ||
13 | +bool addto_dico(dico,string); | ||
14 | + | ||
15 | +void loadfrom_file(dico,FILE*); | ||
16 | +void loadfrom_keyboard(dico); | ||
17 | + | ||
18 | +void printto_file(dico,FILE*); | ||
19 | +void printto_terminal(dico); | ||
20 | + | ||
21 | + | ||
22 | +#endif |
treeh.h
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | 10 | ||
11 | 11 | ||
12 | typedef struct _node node, *tree; | 12 | typedef struct _node node, *tree; |
13 | -struct node{ | 13 | +struct _node{ |
14 | char letter; | 14 | char letter; |
15 | bool isEnd; | 15 | bool isEnd; |
16 | node* next[NBCHAR]; | 16 | node* next[NBCHAR]; |
@@ -24,12 +24,10 @@ void delete_tree(tree); | @@ -24,12 +24,10 @@ void delete_tree(tree); | ||
24 | bool is_empty(tree); | 24 | bool is_empty(tree); |
25 | bool is_end(tree); | 25 | bool is_end(tree); |
26 | bool is_followed(tree);//tells if tree has following letters | 26 | bool is_followed(tree);//tells if tree has following letters |
27 | -int hash(char); | 27 | +int hash(char);//need to check if isalpha |
28 | 28 | ||
29 | void addto_tree(tree,string,int); | 29 | void addto_tree(tree,string,int); |
30 | void addto_tree2(tree,string); | 30 | void addto_tree2(tree,string); |
31 | -void loadfrom_file(tree,FILE*); | ||
32 | -void loadfrom_keyboard(tree); | ||
33 | 31 | ||
34 | 32 | ||
35 | #endif //TREEH_H | 33 | #endif //TREEH_H |