Mercurial > dedupe
comparison BitDecoder.hpp @ 64:b9515dc35fe4
Make sure no file has greater linewidth than 80.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Fri, 14 Sep 2012 22:50:45 +0200 |
| parents | f8d0ea827db3 |
| children |
comparison
equal
deleted
inserted
replaced
| 63:dd086ec3220d | 64:b9515dc35fe4 |
|---|---|
| 17 | 17 |
| 18 uint decode(QString& resString, const BitArray& bits, uint offset) const | 18 uint decode(QString& resString, const BitArray& bits, uint offset) const |
| 19 { | 19 { |
| 20 //Data is always stored in a leaf node. | 20 //Data is always stored in a leaf node. |
| 21 if (high) { | 21 if (high) { |
| 22 return (bits.testBit(offset) ? high : low)->decode(resString, bits, offset + 1) + 1; | 22 return (bits.testBit(offset) ? high : low)-> |
| 23 decode(resString, bits, offset + 1) + 1; | |
| 23 } | 24 } |
| 24 else { | 25 else { |
| 25 resString.append(_data); | 26 resString.append(_data); |
| 26 return 1; | 27 return 1; |
| 27 } | 28 } |
| 36 { | 37 { |
| 37 QString combined; | 38 QString combined; |
| 38 uint n = bits.size(); | 39 uint n = bits.size(); |
| 39 //Just a qualified overestimate guess on what we will need. | 40 //Just a qualified overestimate guess on what we will need. |
| 40 combined.reserve(n/4); | 41 combined.reserve(n/4); |
| 41 for (uint decodedBits = 0; decodedBits < n; decodedBits += decode(combined, bits, decodedBits) - 1); | 42 for (uint decodedBits = 0; decodedBits < n; |
| 43 decodedBits += decode(combined, bits, decodedBits) - 1); | |
| 42 combined.squeeze(); | 44 combined.squeeze(); |
| 43 return combined; | 45 return combined; |
| 44 } | 46 } |
| 45 QString decode(const QString& bits) const; | 47 QString decode(const QString& bits) const; |
| 46 | 48 |
