-
Notifications
You must be signed in to change notification settings - Fork 0
/
struct.h
65 lines (54 loc) · 1.31 KB
/
struct.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#define CHAR 256
/*
* Leaf and hub.
*
* Leafs are meant for characters and hubs
* are for junctions
*
*/
#ifndef STRUCT_H_
#define STRUCT_H_
/*
* Following structs are for representing different types of possible nodes:
* leaf - character, endpoint;
* hub - has two children;
* node - generic node (dont know if hub of leaf).
* Types for previous in same order: 1, 2 (assigned at creation time, we
* dont create actual node type variables, just use it in and crawls!)
* We want to keep structure the same for joint parts (this means that do not change
* the order of items in structures!)
*/
typedef struct nodeleaf {
char type;
struct nodehub *parent;
int freq;
unsigned char ch;
} leaf;
typedef struct nodehub {
char type;
struct nodehub *parent;
int freq;
struct node *left; // as childs can be either leafs or hubs, use generic pointer
struct node *right;
} hub;
typedef struct node {
char type;
struct node *parent;
int freq;
} node;
// End of structures concerned
// Just to ease passing parameters to functions
typedef struct code {
int len;
int ch;
} code;
typedef struct compresscode {
short int code;
char len;
char ch;
} compresscode;
// Root node
hub root;
// Lookup array for nodes
leaf *chararray[CHAR];
#endif // STRUCT_H_