diff options
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | include/BHeap.h | 2 | ||||
-rw-r--r-- | include/BinHeap.h | 2 | ||||
-rw-r--r-- | include/CList.h | 2 | ||||
-rw-r--r-- | include/FHeap.h | 2 | ||||
-rw-r--r-- | include/HTree.h | 6 | ||||
-rw-r--r-- | include/Huffman.h | 10 | ||||
-rw-r--r-- | include/Makefile.am | 2 | ||||
-rw-r--r-- | include/PCommon.h | 2 | ||||
-rw-r--r-- | include/PLList.h | 2 | ||||
-rw-r--r-- | lib/FHeap.cc | 3 | ||||
-rw-r--r-- | lib/HTree.cc | 29 | ||||
-rw-r--r-- | lib/Huffman.cc | 31 | ||||
-rw-r--r-- | lib/Makefile.am | 3 | ||||
-rw-r--r-- | lib/PCommon.cc | 1 | ||||
-rw-r--r-- | lib/SList.cc | 1 | ||||
-rw-r--r-- | po/PriorityLists.pot | 78 | ||||
-rw-r--r-- | po/cat-id-tbl.c | 11 | ||||
-rw-r--r-- | po/de.po | 78 | ||||
-rw-r--r-- | po/fr.po | 78 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/main.cc | 54 | ||||
-rw-r--r-- | src/test.cc | 3 |
23 files changed, 325 insertions, 81 deletions
diff --git a/Makefile.am b/Makefile.am index 3ba0f71..875db83 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,4 @@ localedir = $(datadir)/locale SUBDIRS = lib include doc po intl src -AM_CFLAGS = -Wall -Wstrict-prototypes -g INCLUDES = -I. -I$(includedir) -I../include diff --git a/include/BHeap.h b/include/BHeap.h index d67ab29..9c31467 100644 --- a/include/BHeap.h +++ b/include/BHeap.h @@ -17,7 +17,7 @@ class BHeap:public PriorityList { public: BHeap(void); // Constructor - ~BHeap(void); // Destructor + virtual ~BHeap(void); // Destructor virtual int rn(void); virtual Key_t ReadKey(Cell C); virtual Datas_t ReadDatas(Cell C); diff --git a/include/BinHeap.h b/include/BinHeap.h index 8273365..41872f7 100644 --- a/include/BinHeap.h +++ b/include/BinHeap.h @@ -14,7 +14,7 @@ typedef class BinHeap:public PriorityList { private: void PackUp(int i); public: BinHeap(void); // Constructor - ~BinHeap(void); // Destructor + virtual ~BinHeap(void); // Destructor virtual int rn(void); diff --git a/include/CList.h b/include/CList.h index 147fe71..1bc7fe2 100644 --- a/include/CList.h +++ b/include/CList.h @@ -18,7 +18,7 @@ class CList { public: CList(void); - ~CList(void); + virtual ~CList(void); virtual Datas_t ReadDatas(Cell C); virtual Key_t ReadKey(Cell C); diff --git a/include/FHeap.h b/include/FHeap.h index 65d9253..6cbbeb6 100644 --- a/include/FHeap.h +++ b/include/FHeap.h @@ -19,7 +19,7 @@ typedef class FHeap:public PriorityList { public: FHeap(void); // Constructor - ~FHeap(void); // Destructor + virtual ~FHeap(void); // Destructor virtual int rn(void); diff --git a/include/HTree.h b/include/HTree.h index 18150b1..c153415 100644 --- a/include/HTree.h +++ b/include/HTree.h @@ -11,12 +11,14 @@ class HTree { private: HTree * left, *right; int freq; - Datas_t objet; + char * objet; public: - HTree(int n_freq, char *n_objet); + HTree(int n_freq, char * n_objet); HTree(HTree * n_left, HTree * n_right); ~HTree(); ostream & Trace(ostream & os, int d = 0); + int ReadFreq(void); + char * ReadObj(void); }; #else diff --git a/include/Huffman.h b/include/Huffman.h new file mode 100644 index 0000000..aacbf79 --- /dev/null +++ b/include/Huffman.h @@ -0,0 +1,10 @@ +#ifndef __HUFFMAN_H__ +#define __HUFFMAN_H__ + +#include "PCommon.h" +#include "HTree.h" + +HTree * Coder(PriorityList * P); +void HInsert(PriorityList * P, int freq, char * object); + +#endif
\ No newline at end of file diff --git a/include/Makefile.am b/include/Makefile.am index c0518e5..eeda5cf 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1 +1 @@ -include_HEADERS = PCommon.h PLList.h FHeap.h BHeap.h BinHeap.h CList.h SList.h PTypes.h +include_HEADERS = PCommon.h PLList.h FHeap.h BHeap.h BinHeap.h CList.h SList.h PTypes.h Huffman.h diff --git a/include/PCommon.h b/include/PCommon.h index 1d90a21..e1190fb 100644 --- a/include/PCommon.h +++ b/include/PCommon.h @@ -28,7 +28,7 @@ class PriorityList { public: PriorityList(void); - ~PriorityList(void); + virtual ~PriorityList(void); virtual Key_t ReadKey(Cell C); virtual Datas_t ReadDatas(Cell C); diff --git a/include/PLList.h b/include/PLList.h index 6e9af25..c722900 100644 --- a/include/PLList.h +++ b/include/PLList.h @@ -10,7 +10,7 @@ class PLList:public PriorityList { private: public: PLList(void); - ~PLList(void); + virtual ~PLList(void); virtual Key_t ReadKey(Cell C); virtual Datas_t ReadDatas(Cell C); diff --git a/lib/FHeap.cc b/lib/FHeap.cc index 9f3dc24..158a1e5 100644 --- a/lib/FHeap.cc +++ b/lib/FHeap.cc @@ -136,8 +136,6 @@ Father(NULL), Child(NULL), Left(this), Right(this), Degree(0), Mark(false) FHeap::~FHeap(void) { - FHeap *T; - if (Child) { delete Child; } @@ -277,6 +275,7 @@ bool FHeap::Lower_Key(Cell x, Key_t NKey) } if (NKey < Child->Key) Child = tx; + return true; } Key_t FHeap::Delete(Datas_t & Datas, Cell x) diff --git a/lib/HTree.cc b/lib/HTree.cc index b8731e4..682ac14 100644 --- a/lib/HTree.cc +++ b/lib/HTree.cc @@ -30,10 +30,18 @@ HTree::~HTree() ostream & HTree::Trace(ostream & os, int d) { static char cmpr[MAX_HDEPTH + 1]; + static int tsize; + static int rsize; + static int dsize; + + if (!d) tsize = rsize = dsize = 0; if (objet) { cmpr[d] = '\0'; - os << objet << " = " << cmpr << endl; + os << objet << " (" << freq << ") = " << cmpr << endl; + tsize += freq * strlen(cmpr); + rsize += freq * strlen(objet); + dsize += ((strlen(cmpr) >> 3) + (strlen(cmpr) & 7 ? 1 : 0)) + strlen(objet) + 2; } else { if (left) { cmpr[d] = '0'; @@ -44,5 +52,24 @@ ostream & HTree::Trace(ostream & os, int d) right->Trace(os, d + 1); } } + + if (!d) { + os << _("Bitstream length : ") << tsize << _(" bits (= ") << ((tsize >> 3) + (tsize & 7 ? 1 : 0)) << _(" bytes)\n"); + os << _("Real size input : ") << (rsize << 3) << _(" bits (= ") << rsize << _(" bytes)\n"); + os << _("Size squeezed by : ") << 100.0 - 100.0 * tsize / (rsize << 3) << _(" percents\n"); + os << _("Dictionnary size : ") << (dsize << 3) << _(" bits (= ") << dsize << _(" bytes)\n"); + os << _("Total bitstream length : ") << tsize + (dsize << 3) << _(" bits (= ") << ((tsize >> 3) + (tsize & 7 ? 1 : 0) + dsize) << _(" bytes)\n"); + os << _("Real gain (4 bytes header) : ") << 100.0 - 100.0 * ((tsize >> 3) + (tsize & 7 ? 1 : 0) + dsize + 4) / rsize << _(" percents\n"); + } return os; } + +int HTree::ReadFreq(void) +{ + return freq; +} + +char *HTree::ReadObj(void) +{ + return objet; +} diff --git a/lib/Huffman.cc b/lib/Huffman.cc new file mode 100644 index 0000000..aadf927 --- /dev/null +++ b/lib/Huffman.cc @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <iostream.h> +#include "config.h" +#include "Huffman.h" + +HTree *Coder(PriorityList * P) +{ + int n = P->n(), i, f1, f2; + HTree *x, *y, *z; + Datas_t tx, ty; + + x = y = z = NULL; + + for (i = 0; i < n - 1; i++) { + f1 = P->Extract_Min(tx); + f2 = P->Extract_Min(ty); + x = (HTree *) tx; + y = (HTree *) ty; + z = new HTree(x, y); + P->Insert(z->ReadFreq(), z); + } + + P->Extract_Min(((Datas_t) z)); + return z; +} + +void HInsert(PriorityList * P, int freq, char *object) +{ + HTree * leaf = new HTree(freq, object); + P->Insert(freq, (Datas_t) leaf); +} diff --git a/lib/Makefile.am b/lib/Makefile.am index 71b12e7..10ae1fd 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,10 +1,11 @@ localedir = $(datadir)/locale DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ AM_CFLAGS = -O3 -Wall -Wstrict-prototypes $(CFLAGS) +AM_CXXFLAGS = -O3 -Wall -Wstrict-prototypes $(CXXFLAGS) INCLUDES = -I. -I.. -I$(includedir) -I../include lib_LTLIBRARIES = libPriorityLists.la -libPriorityLists_la_SOURCES = PCommon.cc BHeap.cc FHeap.cc BinHeap.cc PLList.cc CList.cc SList.cc HTree.cc +libPriorityLists_la_SOURCES = PCommon.cc BHeap.cc FHeap.cc BinHeap.cc PLList.cc CList.cc SList.cc HTree.cc Huffman.cc libPriorityLists_la_LDFLAGS = -version-info $(PriorityLists_VERSION_INFO) diff --git a/lib/PCommon.cc b/lib/PCommon.cc index b833a10..1dc3127 100644 --- a/lib/PCommon.cc +++ b/lib/PCommon.cc @@ -50,6 +50,7 @@ PriorityList *PriorityList::GenericUnion(PriorityList * P) IKey = P->Extract_Min(IDatas); Insert(IKey, IDatas); } + return this; } diff --git a/lib/SList.cc b/lib/SList.cc index c65d299..ae2f54f 100644 --- a/lib/SList.cc +++ b/lib/SList.cc @@ -1,4 +1,5 @@ #include <stdio.h> +#include "config.h" #include "SList.h" /**********************\ diff --git a/po/PriorityLists.pot b/po/PriorityLists.pot index ac0d923..81d06a9 100644 --- a/po/PriorityLists.pot +++ b/po/PriorityLists.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2001-03-04 01:43+0100\n" +"POT-Creation-Date: 2001-03-05 02:26+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -44,81 +44,81 @@ msgstr "" msgid " keys (real count). Expecting " msgstr "" -#: src/test.cc:51 src/test.cc:120 +#: src/test.cc:51 src/test.cc:119 msgid "Incorrect order." msgstr "" -#: src/test.cc:67 +#: src/test.cc:66 msgid "Size of a PriorityList cell: " msgstr "" -#: src/test.cc:68 +#: src/test.cc:67 msgid "Size of a BHeap cell : " msgstr "" -#: src/test.cc:69 +#: src/test.cc:68 msgid "Size of a FHeap cell : " msgstr "" -#: src/test.cc:70 +#: src/test.cc:69 msgid "Size of a PLList header : " msgstr "" -#: src/test.cc:71 +#: src/test.cc:70 msgid "Size of a CList cell : " msgstr "" -#: src/test.cc:72 +#: src/test.cc:71 msgid "Size of a SList cell : " msgstr "" -#: src/test.cc:73 +#: src/test.cc:72 msgid "Size of a BinHeap header : " msgstr "" -#: src/test.cc:74 +#: src/test.cc:73 msgid "Size of a BinHeap cell : " msgstr "" -#: src/test.cc:88 +#: src/test.cc:87 msgid "Creating a priority list and adding keys:\n" msgstr "" -#: src/test.cc:100 src/test.cc:107 src/test.cc:111 +#: src/test.cc:99 src/test.cc:106 src/test.cc:110 msgid "" "Ok.\n" "List browsing...\n" msgstr "" -#: src/test.cc:102 +#: src/test.cc:101 msgid "" "Ok.\n" "Extract_Min + List browsing...\n" msgstr "" -#: src/test.cc:105 +#: src/test.cc:104 msgid "" "Ok.\n" "Lower_Key(-12) over 59...\n" msgstr "" -#: src/test.cc:109 +#: src/test.cc:108 msgid "" "Ok.\n" "Delete over 54...\n" msgstr "" -#: src/test.cc:115 +#: src/test.cc:114 msgid "" "Ok.\n" "Extracting datas...\n" msgstr "" -#: src/test.cc:117 +#: src/test.cc:116 msgid "Minimum #" msgstr "" -#: src/test.cc:123 +#: src/test.cc:122 msgid "" "Ok.\n" "\n" @@ -129,15 +129,15 @@ msgstr "" msgid " * Head cell. (" msgstr "" -#: lib/BHeap.cc:224 lib/FHeap.cc:162 +#: lib/BHeap.cc:224 lib/FHeap.cc:160 msgid "Insert: not over Head." msgstr "" -#: lib/BHeap.cc:226 lib/BHeap.cc:246 lib/FHeap.cc:184 +#: lib/BHeap.cc:226 lib/BHeap.cc:246 lib/FHeap.cc:182 msgid "Insert: No more memory." msgstr "" -#: lib/BHeap.cc:268 lib/FHeap.cc:194 lib/PLList.cc:150 +#: lib/BHeap.cc:268 lib/FHeap.cc:192 lib/PLList.cc:150 msgid "Extract_Min: Priority List is empty." msgstr "" @@ -160,3 +160,39 @@ msgid "" " * Head cell\n" " |\n" msgstr "" + +#: lib/HTree.cc:57 +msgid "Bitstream length : " +msgstr "" + +#: lib/HTree.cc:57 lib/HTree.cc:58 lib/HTree.cc:60 lib/HTree.cc:61 +msgid " bits (= " +msgstr "" + +#: lib/HTree.cc:57 lib/HTree.cc:58 lib/HTree.cc:60 lib/HTree.cc:61 +msgid " bytes)\n" +msgstr "" + +#: lib/HTree.cc:58 +msgid "Real size input : " +msgstr "" + +#: lib/HTree.cc:59 +msgid "Size squeezed by : " +msgstr "" + +#: lib/HTree.cc:59 lib/HTree.cc:62 +msgid " percents\n" +msgstr "" + +#: lib/HTree.cc:60 +msgid "Dictionnary size : " +msgstr "" + +#: lib/HTree.cc:61 +msgid "Total bitstream length : " +msgstr "" + +#: lib/HTree.cc:62 +msgid "Real gain (4 bytes header) : " +msgstr "" diff --git a/po/cat-id-tbl.c b/po/cat-id-tbl.c index b7c079f..831b93c 100644 --- a/po/cat-id-tbl.c +++ b/po/cat-id-tbl.c @@ -59,6 +59,15 @@ All the tests were successfull\n", 25}, {"\ * Head cell\n\ |\n", 33}, + {"Bitstream length : ", 34}, + {" bits (= ", 35}, + {" bytes)\n", 36}, + {"Real size input : ", 37}, + {"Size squeezed by : ", 38}, + {" percents\n", 39}, + {"Dictionnary size : ", 40}, + {"Total bitstream length : ", 41}, + {"Real gain (4 bytes header) : ", 42}, }; -int _msg_tbl_length = 33; +int _msg_tbl_length = 42; @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2001-03-04 01:43+0100\n" +"POT-Creation-Date: 2001-03-05 02:26+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -44,81 +44,81 @@ msgstr "" msgid " keys (real count). Expecting " msgstr "" -#: src/test.cc:51 src/test.cc:120 +#: src/test.cc:51 src/test.cc:119 msgid "Incorrect order." msgstr "" -#: src/test.cc:67 +#: src/test.cc:66 msgid "Size of a PriorityList cell: " msgstr "" -#: src/test.cc:68 +#: src/test.cc:67 msgid "Size of a BHeap cell : " msgstr "" -#: src/test.cc:69 +#: src/test.cc:68 msgid "Size of a FHeap cell : " msgstr "" -#: src/test.cc:70 +#: src/test.cc:69 msgid "Size of a PLList header : " msgstr "" -#: src/test.cc:71 +#: src/test.cc:70 msgid "Size of a CList cell : " msgstr "" -#: src/test.cc:72 +#: src/test.cc:71 msgid "Size of a SList cell : " msgstr "" -#: src/test.cc:73 +#: src/test.cc:72 msgid "Size of a BinHeap header : " msgstr "" -#: src/test.cc:74 +#: src/test.cc:73 msgid "Size of a BinHeap cell : " msgstr "" -#: src/test.cc:88 +#: src/test.cc:87 msgid "Creating a priority list and adding keys:\n" msgstr "" -#: src/test.cc:100 src/test.cc:107 src/test.cc:111 +#: src/test.cc:99 src/test.cc:106 src/test.cc:110 msgid "" "Ok.\n" "List browsing...\n" msgstr "" -#: src/test.cc:102 +#: src/test.cc:101 msgid "" "Ok.\n" "Extract_Min + List browsing...\n" msgstr "" -#: src/test.cc:105 +#: src/test.cc:104 msgid "" "Ok.\n" "Lower_Key(-12) over 59...\n" msgstr "" -#: src/test.cc:109 +#: src/test.cc:108 msgid "" "Ok.\n" "Delete over 54...\n" msgstr "" -#: src/test.cc:115 +#: src/test.cc:114 msgid "" "Ok.\n" "Extracting datas...\n" msgstr "" -#: src/test.cc:117 +#: src/test.cc:116 msgid "Minimum #" msgstr "" -#: src/test.cc:123 +#: src/test.cc:122 msgid "" "Ok.\n" "\n" @@ -129,15 +129,15 @@ msgstr "" msgid " * Head cell. (" msgstr "" -#: lib/BHeap.cc:224 lib/FHeap.cc:162 +#: lib/BHeap.cc:224 lib/FHeap.cc:160 msgid "Insert: not over Head." msgstr "" -#: lib/BHeap.cc:226 lib/BHeap.cc:246 lib/FHeap.cc:184 +#: lib/BHeap.cc:226 lib/BHeap.cc:246 lib/FHeap.cc:182 msgid "Insert: No more memory." msgstr "" -#: lib/BHeap.cc:268 lib/FHeap.cc:194 lib/PLList.cc:150 +#: lib/BHeap.cc:268 lib/FHeap.cc:192 lib/PLList.cc:150 msgid "Extract_Min: Priority List is empty." msgstr "" @@ -160,3 +160,39 @@ msgid "" " * Head cell\n" " |\n" msgstr "" + +#: lib/HTree.cc:57 +msgid "Bitstream length : " +msgstr "" + +#: lib/HTree.cc:57 lib/HTree.cc:58 lib/HTree.cc:60 lib/HTree.cc:61 +msgid " bits (= " +msgstr "" + +#: lib/HTree.cc:57 lib/HTree.cc:58 lib/HTree.cc:60 lib/HTree.cc:61 +msgid " bytes)\n" +msgstr "" + +#: lib/HTree.cc:58 +msgid "Real size input : " +msgstr "" + +#: lib/HTree.cc:59 +msgid "Size squeezed by : " +msgstr "" + +#: lib/HTree.cc:59 lib/HTree.cc:62 +msgid " percents\n" +msgstr "" + +#: lib/HTree.cc:60 +msgid "Dictionnary size : " +msgstr "" + +#: lib/HTree.cc:61 +msgid "Total bitstream length : " +msgstr "" + +#: lib/HTree.cc:62 +msgid "Real gain (4 bytes header) : " +msgstr "" @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PriorityList-1.0.0\n" -"POT-Creation-Date: 2001-03-04 01:43+0100\n" +"POT-Creation-Date: 2001-03-05 02:26+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Nicolas Noble <pixel@nobis-crew.org>\n" "Language-Team: French <fr@li.org>\n" @@ -46,47 +46,47 @@ msgstr "Liste corrompue." msgid " keys (real count). Expecting " msgstr " clefs (compte réel) alors que nous attendions " -#: src/test.cc:51 src/test.cc:120 +#: src/test.cc:51 src/test.cc:119 msgid "Incorrect order." msgstr "Ordre incorrect." -#: src/test.cc:67 +#: src/test.cc:66 msgid "Size of a PriorityList cell: " msgstr "Taille d'une cellule du type PriorityList: " -#: src/test.cc:68 +#: src/test.cc:67 msgid "Size of a BHeap cell : " msgstr "Taille d'une cellule du type BHeap : " -#: src/test.cc:69 +#: src/test.cc:68 msgid "Size of a FHeap cell : " msgstr "Taille d'une cellule du type FHeap : " -#: src/test.cc:70 +#: src/test.cc:69 msgid "Size of a PLList header : " msgstr "Taille d'un entète du type PLList : " -#: src/test.cc:71 +#: src/test.cc:70 msgid "Size of a CList cell : " msgstr "Taille d'une cellule du type CList : " -#: src/test.cc:72 +#: src/test.cc:71 msgid "Size of a SList cell : " msgstr "Taille d'une cellule du type SList : " -#: src/test.cc:73 +#: src/test.cc:72 msgid "Size of a BinHeap header : " msgstr "Taille d'un entête du type BinHeap : " -#: src/test.cc:74 +#: src/test.cc:73 msgid "Size of a BinHeap cell : " msgstr "Taille d'une cellule du type BinHeap : " -#: src/test.cc:88 +#: src/test.cc:87 msgid "Creating a priority list and adding keys:\n" msgstr "Création d'une liste de priorité et ajout de clefs:\n" -#: src/test.cc:100 src/test.cc:107 src/test.cc:111 +#: src/test.cc:99 src/test.cc:106 src/test.cc:110 msgid "" "Ok.\n" "List browsing...\n" @@ -94,7 +94,7 @@ msgstr "" "Ok.\n" "Exploration de la liste...\n" -#: src/test.cc:102 +#: src/test.cc:101 msgid "" "Ok.\n" "Extract_Min + List browsing...\n" @@ -102,7 +102,7 @@ msgstr "" "Ok.\n" "Extract_Min + Exploration de la liste...\n" -#: src/test.cc:105 +#: src/test.cc:104 msgid "" "Ok.\n" "Lower_Key(-12) over 59...\n" @@ -110,7 +110,7 @@ msgstr "" "Ok.\n" "Lower_Key(-12) sur 59...\n" -#: src/test.cc:109 +#: src/test.cc:108 msgid "" "Ok.\n" "Delete over 54...\n" @@ -118,7 +118,7 @@ msgstr "" "Ok.\n" "Delete sur 54...\n" -#: src/test.cc:115 +#: src/test.cc:114 msgid "" "Ok.\n" "Extracting datas...\n" @@ -126,11 +126,11 @@ msgstr "" "Ok.\n" "Extraction des données...\n" -#: src/test.cc:117 +#: src/test.cc:116 msgid "Minimum #" msgstr "Minimum #" -#: src/test.cc:123 +#: src/test.cc:122 msgid "" "Ok.\n" "\n" @@ -144,15 +144,15 @@ msgstr "" msgid " * Head cell. (" msgstr " * Cellule d'entête. (" -#: lib/BHeap.cc:224 lib/FHeap.cc:162 +#: lib/BHeap.cc:224 lib/FHeap.cc:160 msgid "Insert: not over Head." msgstr "Insert: pas sur l'entête." -#: lib/BHeap.cc:226 lib/BHeap.cc:246 lib/FHeap.cc:184 +#: lib/BHeap.cc:226 lib/BHeap.cc:246 lib/FHeap.cc:182 msgid "Insert: No more memory." msgstr "Insert: Plus de mémoire." -#: lib/BHeap.cc:268 lib/FHeap.cc:194 lib/PLList.cc:150 +#: lib/BHeap.cc:268 lib/FHeap.cc:192 lib/PLList.cc:150 msgid "Extract_Min: Priority List is empty." msgstr "Extract_Min: File de priorité vide." @@ -179,3 +179,39 @@ msgid "" msgstr "" " * Cellule d'entête.\n" " |\n" + +#: lib/HTree.cc:57 +msgid "Bitstream length : " +msgstr "Taille du flux de bits : " + +#: lib/HTree.cc:57 lib/HTree.cc:58 lib/HTree.cc:60 lib/HTree.cc:61 +msgid " bits (= " +msgstr " bits (= " + +#: lib/HTree.cc:57 lib/HTree.cc:58 lib/HTree.cc:60 lib/HTree.cc:61 +msgid " bytes)\n" +msgstr " octets)\n" + +#: lib/HTree.cc:58 +msgid "Real size input : " +msgstr "Taille réelle de l'entrée : " + +#: lib/HTree.cc:59 +msgid "Size squeezed by : " +msgstr "Taille réduite de : " + +#: lib/HTree.cc:59 lib/HTree.cc:62 +msgid " percents\n" +msgstr " pourcents\n" + +#: lib/HTree.cc:60 +msgid "Dictionnary size : " +msgstr "Taille du dictionnaire : " + +#: lib/HTree.cc:61 +msgid "Total bitstream length : " +msgstr "Taille totale du flux de bits : " + +#: lib/HTree.cc:62 +msgid "Real gain (4 bytes header) : " +msgstr "Gain réel (entête de 4 octets) : " diff --git a/src/Makefile.am b/src/Makefile.am index 03bcc4f..173e832 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,12 +1,15 @@ localedir = $(datadir)/locale DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ AM_CFLAGS = -O3 -Wall -Wstrict-prototypes $(CFLAGS) +AM_CXXFLAGS = -O3 -Wall -Wstrict-prototypes $(CXXFLAGS) INCLUDES = -I. -I.. -I$(includedir) -I../include -bin_PROGRAMS = testTas +bin_PROGRAMS = testTas Huffman testTas_SOURCES = test.cc +Huffman_SOURCES = main.cc LDADD = ../lib/libPriorityLists.la testTas_LDADD = $(LDADD) +Huffman_LDADD = $(LDADD) 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; +} diff --git a/src/test.cc b/src/test.cc index 5a1bce5..bc53810 100644 --- a/src/test.cc +++ b/src/test.cc @@ -20,7 +20,7 @@ void exception(int e, char *msg) PriorityList *newlist(void) { - return new BinHeap; + return new FHeap; } void DoCombTest(int number) @@ -59,7 +59,6 @@ void FullTest(void) { PriorityList *T; Datas_t Datas; - char msg[10240]; Cell C1, C2; Key_t K; int i; |