diff --git a/src/core/pibytearray.cpp b/src/core/pibytearray.cpp index f4e84d48..e8754b70 100755 --- a/src/core/pibytearray.cpp +++ b/src/core/pibytearray.cpp @@ -106,39 +106,6 @@ const char PIByteArray::base64InvTable[256] = { #pragma pack(pop) -int PIHuffman::nodeCompare(const void * f, const void * s) { - return (reinterpret_cast(const_cast(s))->freq - - reinterpret_cast(const_cast(f))->freq); -} - - -PIDeque PIHuffman::compress(const PIDeque & src) { - calcFrequencies(src); - return src; -} - - -void PIHuffman::calcFrequencies(const PIDeque & src) { - nodes.resize(256); - for (int i = 0; i < 256; ++i) { - nodes[i].parent = nodes[i].right = nodes[i].left = 0; - nodes[i].freq = 0; - nodes[i].word.resize(1); - nodes[i].word[0] = static_cast(i); - } - for (int i = 0; i < src.size_s(); ++i) - nodes[src[i]].freq++; - std::qsort(nodes.data(), 256, sizeof(node), nodeCompare); - for (int i = 255; i >= 0; --i) - if (nodes[i].freq > 0 && i < 255) - {nodes.remove(i + 1, 255 - i); break;} - for (int i = 0; i < nodes.size_s(); ++i) - std::cout << std::string((char*)nodes[i].word.data(), 1) << ": " << nodes[i].freq << std::endl; -} - - -PIHuffman PIByteArray::huffman; - PIByteArray & PIByteArray::convertToBase64() { base64HelpStruct hs; PIByteArray t; diff --git a/src/core/pibytearray.h b/src/core/pibytearray.h index 40c8af13..73e394b3 100755 --- a/src/core/pibytearray.h +++ b/src/core/pibytearray.h @@ -33,23 +33,6 @@ class PIString; class PIByteArray; -class PIHuffman { -public: - PIDeque compress(const PIDeque & src); - -private: - struct node { - int freq; - PIDeque word; - PIBitArray path; - node * parent; - node * right; - node * left; - }; - static int nodeCompare(const void * f, const void * s); - void calcFrequencies(const PIDeque & src); - PIVector nodes; -}; class PIP_EXPORT PIByteArray: public PIDeque { @@ -100,8 +83,6 @@ public: PIByteArray compressedRLE(uchar threshold = 192) {PIByteArray ba(*this); ba.compressRLE(threshold); return ba;} PIByteArray decompressedRLE(uchar threshold = 192) {PIByteArray ba(*this); ba.decompressRLE(threshold); return ba;} - PIByteArray & compressHuffman() {*this = huffman.compress(*this); return *this;} - PIString toString(int base = 16) const; //! Add to the end data "data" with size "size" @@ -145,7 +126,6 @@ private: static const char base64Table[64]; static const char base64InvTable[256]; - static PIHuffman huffman; };