自顺应霍夫曼编码的C++版本简单实现classAdaptiveTree{public: AdaptiveTree(introotNum); AdaptiveTree(introotNum,stringstr); voidswap(intfirst,intsecond);   //swaptwonodesofthetree voidinitalCode();       //initializingthedata stringchar2code(unsignedcharletter);  //locatethecharacterinthetreewithitscorrespondingbinarystringandreturnthestring stringchar2binary(unsignedcharletter); //translatingthecharactertothe8-bitbinarystring unsignedcharbinary2char(stringbin);  //translatingthebinarystring:bintothecorrespondingcharacter intspawn(unsignedcharletter);   //addanewcharactertotheoriginaltree voidupdateTree(unsignedcharnewchar);  //updatethetree inthighestInBlock(intcount);    //returnthehighestnodetobeexchanged voidsetString(stringstr);     // stringdecodingStr()const; voidencoding(); stringdecoding(); unsignedcharcode2char(stringbincode); staticintsize();  stringbinStr()const;//returnthebinarystringofstring:tempStringprivate: voidrun(); intfindchar(unsignedcharletter);  //locatetheletterinthetree stringtempString;       //tempstringtobeencodedneededtobestoredhere  stringdeStr;//usedforstoringthedecodingstring stringbin;//usedforstoringtheresultofencodingprocess /*AdaptiveTreedatamembers*/ HuffmanTree*tree;introot; /*AdaptiveTreeconstants*/ staticintALPH_SIZE;//sizeofthealphabetstaticunsignedcharnone;//notaunsignedcharacterstaticunsignedcharNYT;//NotYettransmittedcode};
                                    
                                    
                                        
                                            1