本文整理汇总了C++中BitArray::getArray方法的典型用法代码示例。如果您正苦于以下问题:C++ BitArray::getArray方法的具体用法?C++ BitArray::getArray怎么用?C++ BitArray::getArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitArray
的用法示例。
在下文中一共展示了BitArray::getArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writefile
void Tree::writefile(char *pathIn){
ifstream file;
ofstream write;
string aux;
string aux2;
string temporaria;
int sobra = 0;
int sizefile = 0;
BitArray *buffer = new BitArray();
aux.clear();
temporaria.clear();
codificar(root, aux);
aux.clear();
file.open(pathIn , ios::in | ios::binary | ios::ate);
if(file.is_open()){
int size = file.tellg();
file.seekg(0, ios::beg);
int i;
int iw =1;
for(i=0; i< size; i++){
unsigned char c = file.get();
int j = c;
aux += codeNodes[j];
if(aux.length() >= 1024*8){
sobra = aux.length() - 1024*8;
temporaria = aux.substr(1024*8, sobra);
for(int k = 0;k < (aux.length()/8); k++){
int n = k*8;
aux2 = aux.substr(n, 8);
codenode_to_bitarray(aux2, buffer);
}
iw++;
write.open("temp.huff", ios::out | ios::binary | ios::app);
if(write.is_open()){
for(int z = 0;z < aux.length()/8;z++){
write << buffer->getArray()[z];
sizefile++;
}
}
write.close();
aux.clear();
aux = temporaria;
buffer->clear();
}
}
int y = (aux.length()/8);
sobra = aux.length() - (y*8);
aux2 = aux.substr(y*8,sobra);
string teste = aux2;
for(int k = 0;k < (aux.length()/8); k++){
int n = k*8;
aux2 = aux.substr(n, 8);
codenode_to_bitarray(aux2, buffer);
}
int u = 8 - sobra;
sizeTrash = u;
aux2 = teste;
for(int i = 0;i < u;i++){
aux2 += '0';
}
codenode_to_bitarray(aux2, buffer);
sizeLast = (buffer->getCurrent() / 8);
sizeLast--;
write.open("temp.huff", ios::out | ios::binary | ios::app);
if(write.is_open()){
for(int z=0; z <= sizeLast;z++){
write << buffer->getArray()[z];
sizefile++;
}
}
write.close();
sizeTrash = buffer->trashLenght();
buffer->clear();
}
else cout << "TRASH!in WriteFile" << endl;
file.close();
}
示例2: buildHeader
void Tree::buildHeader(string filename){
string aux_s;
string aux_s2;
BitArray *bit = new BitArray();
int aux_bit;
int k;
aux_s.clear();
writeTree(root, aux_s);
aux_s.clear();
tree_written = tree_written.substr(1,tree_written.length()-2);
sizeTree = tree_written.length();
equilibrar(tree_written);
switch (sizeTrash) {
case 1:
aux_s = "001";
break;
case 2:
aux_s = "010";
break;
case 3:
aux_s = "011";
break;
case 4:
aux_s = "100";
break;
case 5:
aux_s = "101";
break;
case 6:
aux_s = "110";
break;
case 7:
aux_s = "111";
break;
case 8:
aux_s = "000";
default:
break;
}
aux_bit = sizeTree/2;
if(sizeTree%2 == 1){
aux_s2 = "1";
}
else if(sizeTree%2 == 0){
aux_s2 = "0";
}
aux_bit = sizeTree;
while(aux_bit > 1){
aux_bit = aux_bit/2;
if(aux_bit % 2 == 1){
aux_s2 += "1";
}
else if(aux_bit % 2 == 0){
aux_s2 += "0";
}
}
aux_bit = 13 - aux_s2.length();
reverse(aux_s2.begin(), aux_s2.end());
for(int i=0; i < aux_bit; i++){
aux_s += "0";
}
aux_s += aux_s2;
codenode_to_bitarray(aux_s.substr(0,8), bit);
codenode_to_bitarray(aux_s.substr(8,8), bit);
aux_s.clear();
k = 3 + filename.length() + sizeTree;
header = new unsigned char[k];
header = bit->getArray();
unsigned char c = filename.length();
header[2] = c;
int w =0;
for(int i =0; i<filename.length();i++){
w = i +3;
header[w] = filename[i];
}
w = 0;
int j = 3 + filename.length();
for(int i = 0;i< sizeTree;i++){
w = i+j;
header[w] = tree_written[i];
}
sizeHeader = k;
sizeFileName = filename.length();
for(int i=0;i<k;i++);
}