treeh.h
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef TREEH_H
#define TREEH_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define NBCHAR 26 //A-Z
typedef char *string,byte;
typedef struct _node node, *tree;
struct _node{
char letter;
byte isEnd;
//0 no,1 yes,+2 if ends with 's
//*4 if proper, *16 if allUpper
node* next[NBCHAR];
};
tree make_empty_tree();//create a null node*
node* make_empty_node();//malloc a node and initialize it
node* make_node(char,byte);//id
void delete_tree(tree);//free(tree) and delete tree on all t->next
bool is_empty(const tree);//==NULL
bool is_followed(const tree);//if true tree has following letters
bool is_end(const tree);//if true word can end here
bool ends_with_apostrophe(const tree);//if true word can be word's
bool is_common_end(const tree);//if true all letters are lower
bool is_proper_end(const tree);//if true 1st letter is upper
bool is_acronyme_end(const tree);//if true all letters are upper
int hash(char);//need to check if isalpha
//recursive can only be called in a dico instance
//
bool addto_tree(tree,const string,byte);
void addto_tree2(tree,const string,byte);
#endif //TREEH_H