Add Tuple struct with precomputed inverse index

This commit is contained in:
Jordan Sherer
2018-10-02 18:03:15 -04:00
parent 2cb1665e2e
commit 7f992433dc
7 changed files with 229498 additions and 467328 deletions
+40 -36
View File
@@ -1550,42 +1550,8 @@ QString Varicode::packDataMessage(const QString &input, int *n){
static const int frameSize = 72;
QString frame;
QVector<bool> frameBits;
frameBits.append(Varicode::intToBits(FrameDataPadded, 3));
int i = 0;
foreach(auto pair, JSC::compress(input)){
auto bits = pair.first;
auto chars = pair.second;
if(frameBits.length() + bits.length() < frameSize){
frameBits.append(bits);
i += chars;
continue;
}
break;
}
int pad = frameSize - frameBits.length();
if(pad){
// the way we will pad is this...
// set the bit after the frame to 0 and every bit after that a 1
// to unpad, seek from the end of the bits until you hit a zero... the rest is the actual frame.
for(int i = 0; i < pad; i++){
frameBits.append(i == 0 ? (bool)0 : (bool)1);
}
}
quint64 value = Varicode::bitsToInt(frameBits.constBegin(), 64);
quint8 rem = (quint8)Varicode::bitsToInt(frameBits.constBegin() + 64, 8);
frame = Varicode::pack72bits(value, rem);
*n = i;
#if 0
#if USE_HUFF_DATA_PACKING
// [3][69] = 72
QVector<bool> frameDataBits;
@@ -1625,6 +1591,40 @@ QString Varicode::packDataMessage(const QString &input, int *n){
quint8 rem = (quint8)Varicode::bitsToInt(allBits.constBegin() + 64, 8);
frame = Varicode::pack72bits(value, rem);
*n = i;
#else
QVector<bool> frameBits;
frameBits.append(Varicode::intToBits(FrameDataPadded, 3));
int i = 0;
foreach(auto pair, JSC::compress(input)){
auto bits = pair.first;
auto chars = pair.second;
if(frameBits.length() + bits.length() < frameSize){
frameBits.append(bits);
i += chars;
continue;
}
break;
}
int pad = frameSize - frameBits.length();
if(pad){
// the way we will pad is this...
// set the bit after the frame to 0 and every bit after that a 1
// to unpad, seek from the end of the bits until you hit a zero... the rest is the actual frame.
for(int i = 0; i < pad; i++){
frameBits.append(i == 0 ? (bool)0 : (bool)1);
}
}
quint64 value = Varicode::bitsToInt(frameBits.constBegin(), 64);
quint8 rem = (quint8)Varicode::bitsToInt(frameBits.constBegin() + 64, 8);
frame = Varicode::pack72bits(value, rem);
*n = i;
#endif
@@ -1642,7 +1642,6 @@ QString Varicode::unpackDataMessage(const QString &text, quint8 *pType){
quint64 value = Varicode::unpack72bits(text, &rem);
auto bits = Varicode::intToBits(value, 64) + Varicode::intToBits(rem, 8);
#if 0
quint8 type = Varicode::bitsToInt(bits.mid(0, 3));
if(type == FrameDataUnpadded){
bits = bits.mid(3);
@@ -1653,12 +1652,17 @@ QString Varicode::unpackDataMessage(const QString &text, quint8 *pType){
return unpacked;
}
#if USE_HUFF_DATA_PACKING
// huff decode the bits (without escapes)
unpacked = Varicode::huffDecode(hufftable, bits);
// then... unescape special characters
unpacked = Varicode::huffUnescape(unpacked);
if(pType) *pType = type;
#else
unpacked = JSC::decompress(bits);
if(pType) *pType = type;
#endif