int AbstractNumberModel<T>::decompressBeforeAfter(BinaryCode& code, string& beforeAfter) const{ if(code.finish()) return -1; bool mark = code.getFirstBitMoveToNext(); if(mark){ return dictModelPtr->decompressWord(code, beforeAfter); } else{ beforeAfter = ""; return 0; } }
int GammaEncoder::decode(BinaryCode& code, unsigned int& num) const{ unsigned int len; int ret = unary.decode(code, len); if(ret == -1) return -1; unsigned int remaining = len - 1; num = 1; if(code.remainSize() < remaining) return -1; for(unsigned int i = 0; i < remaining; i++){ num = (num << 1) + code.getFirstBitMoveToNext(); } return 0; }