summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorPixel <>2001-03-05 01:30:36 +0000
committerPixel <>2001-03-05 01:30:36 +0000
commitdfd868ecf9e37a5e6954a073c3ba43a970f7ca54 (patch)
tree3c85775253afaa6c43148a8da46fa8a7803de62e /src/main.cc
parentf1eb23d8a489aa0353b68aba47c065e3206920ac (diff)
Projet quasi fini...
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main.cc b/src/main.cc
new file mode 100644
index 0000000..520f6ec
--- /dev/null
+++ b/src/main.cc
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "BHeap.h"
+#include "FHeap.h"
+#include "BinHeap.h"
+#include "PLList.h"
+#include "Huffman.h"
+
+void exception(int e, char *msg)
+{
+ fprintf(stderr, "%s\n", msg);
+ exit(-1);
+}
+
+PriorityList *newlist(void)
+{
+ return new BinHeap;
+}
+
+void Count(FILE * strm, PriorityList * P)
+{
+ int tab[256], i;
+ char *t;
+
+ for (i = 0; i < 256; i++) {
+ tab[i] = 0;
+ }
+
+ while ((i = getc(strm)) != EOF) {
+ tab[i]++;
+ }
+
+ for (i = 0; i < 256; i++) {
+ if (tab[i]) {
+ t = (char *) malloc(2);
+ t[0] = i;
+ t[1] = 0;
+ HInsert(P, tab[i], t);
+ }
+ }
+}
+
+int main(int argc, char **argv)
+{
+ PriorityList *P = newlist();
+ HTree *H;
+
+ Count(stdin, P);
+
+ H = Coder(P);
+ H->Trace(cout);
+ return 0;
+}