本文整理汇总了C++中BitString::setBit方法的典型用法代码示例。如果您正苦于以下问题:C++ BitString::setBit方法的具体用法?C++ BitString::setBit怎么用?C++ BitString::setBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitString
的用法示例。
在下文中一共展示了BitString::setBit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DecodingTree
DecodingTree*
Huffman::obtainSubtree(uint symbol, uint k)
{
BinaryNode *node = tree;
// Traversing the Huffman tree
for (uint i=1; i<=k; i++)
{
bool bit = ((symbol >> (k-i)) & 1);
if (bit == 0) node = node->leftChild;
else node = node->rightChild;
}
// Retrieving the subtree
vector<uint> xTree;
vector<uint> symbols;
uint bits = 0;
retrieveSubtree(node, &xTree, &bits, &symbols);
BitString *tree = new BitString(2*xTree.size());
for (uint i=0; i<xTree.size(); i++) tree->setBit(xTree[i]);
return new DecodingTree(symbol, tree, &symbols);
}
示例2: make_pair
pair<BitString *,uint> generateBitmap(size_t length,vector<pair<uint,uint> > &nodes ) {
uint bitmap_pos = 0;
BitString *bitmap = new BitString(length);
size_t a,b;
cst->Root(&a,&b);
bitmap_pos++;
// cout << "(" ;
generateBitmapAux(make_pair(a,b),bitmap,bitmap_pos,nodes);
bitmap->setBit(bitmap_pos);
bitmap_pos++;
// cout << ")";
// cout << "nodes.size() = " << nodes.size() << endl;
BitString *new_bitmap = new BitString(bitmap->getData(),bitmap_pos);
// for (int i = 0 ; i < nodes.size();i++) {
// cout << nodes[i].first << endl;
// }
// cout << "=========== tree ==========" << endl;
// for (int i = 0 ;i < bitmap_pos;i++) {
// if (bitmap->getBit(i))
// cout << ")";
// else
// cout << "(";
// }
// cout << endl;
return make_pair(new_bitmap,bitmap_pos);
}