本文整理汇总了C++中BitVector::count方法的典型用法代码示例。如果您正苦于以下问题:C++ BitVector::count方法的具体用法?C++ BitVector::count怎么用?C++ BitVector::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector::count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepareNodes
bool
SpillPlacement::placeSpills(const SmallVectorImpl<BlockConstraint> &LiveBlocks,
BitVector &RegBundles) {
// Reuse RegBundles as our ActiveNodes vector.
ActiveNodes = &RegBundles;
ActiveNodes->clear();
ActiveNodes->resize(bundles->getNumBundles());
// Compute active nodes, links and biases.
prepareNodes(LiveBlocks);
// Update all active nodes, and find the ones that are actually linked to
// something so their value may change when iterating.
DEBUG(dbgs() << "Network has " << RegBundles.count() << " active nodes:\n");
SmallVector<unsigned, 8> Linked;
for (int n = RegBundles.find_first(); n>=0; n = RegBundles.find_next(n)) {
nodes[n].update(nodes);
// A node that must spill, or a node without any links is not going to
// change its value ever again, so exclude it from iterations.
if (!nodes[n].Links.empty() && !nodes[n].mustSpill())
Linked.push_back(n);
DEBUG({
dbgs() << " EB#" << n << format(" = %+2.0f", nodes[n].Value)
<< format(", Bias %+.2f", nodes[n].Bias)
<< format(", Freq %.1f/%.1f", nodes[n].Frequency[0],
nodes[n].Frequency[1]);
for (unsigned i = 0, e = nodes[n].Links.size(); i != e; ++i)
dbgs() << format(", %.2f -> EB#%u", nodes[n].Links[i].first,
nodes[n].Links[i].second);
dbgs() << '\n';
});
}
示例2: main
int main() {
init_bit_vector(0);
{for (unsigned i = 0; i < 1600; i++) {
BitVector bv;
bv.set_bit(i, true);
BitVectorIter iter(&bv);
if (!iter.is_valid()) {
fprintf(stderr, "ERROR: %d\n", i);
continue;
}
size_t val = iter.current();
if (val != i) {
fprintf(stderr, "ERROR: %d\n", i);
continue;
}
if (bv.count() != 1) {
fprintf(stderr, "ERROR: %d\n", i);
continue;
}
iter.next();
if (iter.is_valid()) {
fprintf(stderr, "ERROR: %d\n", i);
continue;
}
}}
{for (unsigned i = 24; i < 160; i++) {
BitVector bv;
bv.set_bit(i, true);
for (unsigned j = 32; j < 160; j++) {
if (j > 0 && j != i+1) bv.set_bit(j-1, false);
if (i == j) continue;
bv.set_bit(j, true);
BitVectorIter iter(&bv);
if (!iter.is_valid()) {
fprintf(stderr, "ERROR: %d %d\n", i, j);
continue;
}
size_t val = iter.current();
if (bv.count() != 2) {
fprintf(stderr, "ERROR: %d %d\n", i, j);
continue;
}
iter.next();
size_t val2 = iter.current();
if (!iter.is_valid()) {
fprintf(stderr, "ERROR: %d %d\n", i, j);
continue;
}
if (!((val == i && val2 == j) ||
(val == j && val2 == i))) {
fprintf(stderr, "ERROR: %d %d\n", i, j);
continue;
}
iter.next();
if (iter.is_valid()) {
fprintf(stderr, "ERROR: %d %d\n", i, j);
continue;
}
}
}}
return(0);
}