Mercurial > dedupe
comparison HuffmanSet.hpp @ 49:f8d0ea827db3
Use BitArray.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Mon, 10 Sep 2012 23:59:46 +0200 |
| parents | f711ddb56ae7 |
| children | 19b2a2d98788 |
comparison
equal
deleted
inserted
replaced
| 48:ef429402e03b | 49:f8d0ea827db3 |
|---|---|
| 1 #ifndef HUFFMANSET_HPP | 1 #ifndef HUFFMANSET_HPP |
| 2 #define HUFFMANSET_HPP | 2 #define HUFFMANSET_HPP |
| 3 | 3 |
| 4 #include "BitDecoder.hpp" | |
| 5 | |
| 6 #include <QtCore/QBitArray> | |
| 7 #include <QtCore/QMap> | 4 #include <QtCore/QMap> |
| 8 #include <QtCore/QString> | 5 #include <QtCore/QString> |
| 9 #include <QtCore/QStringList> | 6 #include <QtCore/QStringList> |
| 7 | |
| 8 #include "BitArray.hpp" | |
| 9 | |
| 10 class BitDecoder; | |
| 11 class FastBitDecoder; | |
| 10 | 12 |
| 11 class HuffmanSet { | 13 class HuffmanSet { |
| 12 public: | 14 public: |
| 13 typedef uint key_t; | 15 typedef uint key_t; |
| 14 | 16 |
| 15 private: | 17 private: |
| 16 QMap<key_t, QString> newStrings; | 18 QMap<key_t, QString> newStrings; |
| 17 QMap<key_t, QBitArray> map; | 19 QMap<key_t, BitArray> map; |
| 18 QMap<QString, QBitArray> encoder; | 20 QMap<QString, BitArray> encoder; |
| 19 uint cutoff; | 21 uint cutoff; |
| 20 uint numInserts; | 22 uint numInserts; |
| 23 //FastBitDecoder* lut; | |
| 21 BitDecoder* lut; | 24 BitDecoder* lut; |
| 22 | 25 |
| 23 | 26 |
| 24 public: | 27 public: |
| 25 HuffmanSet(); | 28 HuffmanSet(); |
| 26 void setCutoff(uint cutoff); | 29 void setCutoff(uint cutoff); |
| 27 static QStringList chunks(const QString& str); | 30 static QStringList chunks(const QString& str); |
| 28 BitDecoder* createLut(const QMap<QString, uint>& freqTable); | 31 BitDecoder* createLut(const QMap<QString, uint>& freqTable); |
| 29 QString decode(const QBitArray& bits) const; | 32 QString decode(const BitArray& bits) const; |
| 30 static QBitArray encode(const QString& string, const QMap<QString, QBitArray>& encoder); | 33 static BitArray encode(const QString& string, const QMap<QString, BitArray>& encoder); |
| 31 void rebuild(); | 34 void rebuild(); |
| 32 bool contains(key_t key) const; | 35 bool contains(key_t key) const; |
| 33 uint totalElements() const; | 36 uint totalElements() const; |
| 34 key_t hash(const QString& str); | 37 key_t hash(const QString& str); |
| 35 key_t insert(const QString& str); | 38 key_t insert(const QString& str); |
