-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrays.h
More file actions
96 lines (70 loc) · 1.75 KB
/
Arrays.h
File metadata and controls
96 lines (70 loc) · 1.75 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*========================================================================*/
/* Huffman Statistic Coding ---- Arrays */
/*========================================================================*/
/*========================================================================*/
#include <alloc.h>
/*========================================================================*/
#define _ARRAYS_ 0
#ifndef _TREE_
#include "tree.h"
#endif
#ifndef false
#define false 0
#define true 1
typedef int bool;
#endif
/*========================================================================*/
typedef struct
{
Tree *tree; /* Tree.h */
}
Arrays;
/*========================================================================*/
bool InitArrays ();
bool InsertArrays (unsigned char v);
bool DeleteArrays ();
/*========================================================================*/
Arrays *arrays;
/*========================================================================*/
bool InitArrays ()
{
int i;
arrays=malloc(sizeof(Arrays)*256); /* alloc.h */
if (arrays)
{
for (i=0;i<256;i++)
arrays[i].tree=NULL; /* alloc.h */
return true;
}
else
return false;
}
/*========================================================================*/
bool InsertArrays (unsigned char v)
{
if (arrays[v].tree)
{
arrays[v].tree->count++;
return true;
}
else
{
arrays[v].tree=MakeTree(); /* Tree.h */
if (arrays[v].tree)
{
arrays[v].tree->value=v;
arrays[v].tree->count=1;
return true;
}
else
return false;
}
}
/*========================================================================*/
bool DeleteArrays ()
{
free (arrays); /* alloc.h */
return true;
}
/*========================================================================*/