Blame view

treeh.h 1.43 KB
a4ef278c   bjeanlou   init withHash
1
2
3
4
5
6
  #ifndef TREEH_H
  #define TREEH_H
  
  #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
4043090f   bjeanlou   update2 withHash
7
  #include <stdbool.h>
cf53766d   bjeanlou   update2 dico
8
  #include <ctype.h>
a4ef278c   bjeanlou   init withHash
9
  
de5faa60   bjeanlou   Update isEnd
10
  #define NBCHAR 26 //A-Z
a4ef278c   bjeanlou   init withHash
11
  
a89bb625   bjeanlou   Update 8 withHash
12
  #define NOT_AN_END 0x00
08822d77   bjeanlou   Update 9 withHash
13
  
003d3e48   bjeanlou   update6 withHash
14
  #define COMMON_END 0x03
08822d77   bjeanlou   Update 9 withHash
15
  #define PROPER_END 0x0C
003d3e48   bjeanlou   update6 withHash
16
  #define ACRONYME_END 0x30
08822d77   bjeanlou   Update 9 withHash
17
  
a89bb625   bjeanlou   Update 8 withHash
18
19
  #define STRAIGHT_END 0x15
  #define APOSTROPHE_END 0x2A
003d3e48   bjeanlou   update6 withHash
20
  
f48297ea   bjeanlou   Update1 treeh
21
  typedef char *string,byte;
4043090f   bjeanlou   update2 withHash
22
  typedef struct _node node, *tree;
0bc3d1ad   bjeanlou   dico created
23
  struct _node{
a4ef278c   bjeanlou   init withHash
24
    char letter;
f48297ea   bjeanlou   Update1 treeh
25
    byte isEnd;
de5faa60   bjeanlou   Update isEnd
26
    //0 no,1 yes,+2 if ends with 's
17b49163   bjeanlou   Update2 treeh
27
    //*4 if proper, *16 if allUpper 
4043090f   bjeanlou   update2 withHash
28
29
    node* next[NBCHAR];
  };
a4ef278c   bjeanlou   init withHash
30
  
de5faa60   bjeanlou   Update isEnd
31
32
  tree make_empty_tree();//create a null node*
  node* make_empty_node();//malloc a node and initialize it
f48297ea   bjeanlou   Update1 treeh
33
  node* make_node(char,byte);//id
ccb47d03   bjeanlou   menu quit ok
34
  void delete_tree(tree*);//free(tree) and delete tree on all t->next
de5faa60   bjeanlou   Update isEnd
35
  
f48297ea   bjeanlou   Update1 treeh
36
37
  bool is_empty(const tree);//==NULL
  bool is_followed(const tree);//if true tree has following letters
de5faa60   bjeanlou   Update isEnd
38
  
fb520d8f   bjeanlou   v1 ended
39
40
  
  //endKind functions
003d3e48   bjeanlou   update6 withHash
41
42
43
  bool is_end(const tree);//true when  at least 1 of the following functions is true
  bool is_straight_end(const tree);//if true word can end here
  bool ends_with_apostrophe(const tree);//if true word can end here with apostrophe
f48297ea   bjeanlou   Update1 treeh
44
45
46
  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
4043090f   bjeanlou   update2 withHash
47
  
fb520d8f   bjeanlou   v1 ended
48
49
  
  //other
0bc3d1ad   bjeanlou   dico created
50
  int hash(char);//need to check if isalpha
11c78e6d   bjeanlou   update5 withHash
51
52
53
  bool ischar_of_word(char);//tells if char can be in a word
  bool is_word(byte endKind);//pass end_kind() as parameter
  byte end_kind(string);
a4ef278c   bjeanlou   init withHash
54
  
a4ef278c   bjeanlou   init withHash
55
  
a4ef278c   bjeanlou   init withHash
56
  #endif //TREEH_H