Mercurial > dedupe
comparison FastBitDecoder.hpp @ 57:c8111de2e0bb
Add functionality to decode directly from bitstring.
Use BitArrays getPaddedChar directly.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Thu, 13 Sep 2012 23:53:35 +0200 |
| parents | f8d0ea827db3 |
| children | b9515dc35fe4 |
comparison
equal
deleted
inserted
replaced
| 56:76846cb92b5c | 57:c8111de2e0bb |
|---|---|
| 21 void insert(const BitArray& key, const QString& value); | 21 void insert(const BitArray& key, const QString& value); |
| 22 uint decode(QString& resString, const BitArray& bits, uint offset) const; | 22 uint decode(QString& resString, const BitArray& bits, uint offset) const; |
| 23 | 23 |
| 24 public: | 24 public: |
| 25 FastBitDecoder(const QMap<QString, BitArray>& encoder); | 25 FastBitDecoder(const QMap<QString, BitArray>& encoder); |
| 26 ~FastBitDecoder(); | |
| 27 | |
| 28 QString decode(const QString& bits) const; | |
| 29 | |
| 26 QString decode(const BitArray& bits) const | 30 QString decode(const BitArray& bits) const |
| 27 { | 31 { |
| 28 QString combined; | 32 QString combined; |
| 29 uint n = bits.size(); | 33 uint n = bits.size(); |
| 30 //Just a qualified overestimate guess on what we will need. | 34 //Just a qualified overestimate guess on what we will need. |
| 31 combined.reserve(n/4); | 35 combined.reserve(n/4); |
| 32 for (uint decodedBits = 0; decodedBits < n; decodedBits += decode(combined, bits, decodedBits)); | 36 for (uint decodedBits = 0; decodedBits < n; decodedBits += decode(combined, bits, decodedBits)); |
| 33 combined.squeeze(); | 37 combined.squeeze(); |
| 34 return combined; | 38 return combined; |
| 35 } | 39 } |
| 36 QString decode(const QString& bits) const; | |
| 37 | 40 |
| 38 | 41 |
| 39 }; | 42 }; |
| 40 | 43 |
| 41 #endif //BITDECODER_HPP | 44 #endif //BITDECODER_HPP |
