本文整理汇总了C++中HuffmanTree::uncoding方法的典型用法代码示例。如果您正苦于以下问题:C++ HuffmanTree::uncoding方法的具体用法?C++ HuffmanTree::uncoding怎么用?C++ HuffmanTree::uncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HuffmanTree
的用法示例。
在下文中一共展示了HuffmanTree::uncoding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
ifstream image;
image.open("/home/cxy229/image/data.dat");
if(!image.good()) //文件未成功打开
{
cerr<<" error:: unable to open image! "<<endl;
exit(1);
}
char aaaa[4]={'a','b','c','d'};
int w[4]={5,6,7,8};
HuffmanTree<char> test;
test.setTree(w,aaaa,4,0);
test.encode(test.getroot(),"");
cout<<"d:"<<test.coding('d')<<endl;
cout<<"c:"<<test.coding('c')<<endl;
cout<<"b:"<<test.coding('b')<<endl;
cout<<"a:"<<test.coding('a')<<endl;
cout<<test.uncoding("010110");
cout<<endl;
imgCompressor img;
img.run();
return 0;
}
示例2: decompresse
void imgCompressor::decompresse()
{
ifstream img_com;
img_com.open("/home/cxy229/image/img_compressed");
if(!img_com.good()) //文件未成功打开
{
cerr<<" error:: unable to open img_compressed! "<<endl;
exit(1);
}
ofstream img_decom("/home/cxy229/image/img_decompressed",ios::out|ios::app);
if(!img_decom)
{
cout<<" fail to open img_decom"<<endl;
exit(1);
}
char temp[100];
string str;
while(!img_com.eof())
{
img_com.getline(temp,99);
str = swich(temp,strlen(temp));
//cout<<str;
img_decom<<h_tree.uncoding(str)<<endl;
}
img_com.close();
img_decom.close();
}