本文整理汇总了C++中boost::dynamic_bitset::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ dynamic_bitset::resize方法的具体用法?C++ dynamic_bitset::resize怎么用?C++ dynamic_bitset::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::dynamic_bitset
的用法示例。
在下文中一共展示了dynamic_bitset::resize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serialize
void serialize(input_archive& ar,
boost::dynamic_bitset<Block, Alloc>& bs, unsigned)
{
std::size_t num_bits;
std::vector<Block> blocks;
ar >> num_bits;
ar >> blocks;
bs.resize(num_bits);
boost::from_block_range(blocks.begin(), blocks.end(), bs);
bs.resize(num_bits);
}
示例2: set
unsigned int cliqueHelper3(const boost_graph &g, const std::vector<VertexID> &nodes, const std::vector<EdgeID> &edges, double &score)
{
static boost::dynamic_bitset<> empty;
empty.resize(nodes.size());
unsigned largest_clique = 1;
boost::dynamic_bitset<> set(nodes.size());
for (unsigned i = 0; i < nodes.size(); ++i)
{
set[i] = true;
}
int i = 0;
while ((largest_clique <= 1 || i < 50000) && i < 100000)
{
// build the next potential clique.
// every bit that is a 1 in set means that that node is in the clique.
std::vector<VertexID> clique;
randomize(set);
set[0] = true; // the first bit is the query node. must always be on.
for (unsigned loop = 0; loop < nodes.size(); ++loop)
{
if (set[loop])
{
clique.push_back(nodes[loop]);
}
}
// if this is a clique..
double maybe_score = 0;
if ((clique.size() > largest_clique) && isClique(g, clique, edges, maybe_score))
{
largest_clique = clique.size();
score = maybe_score;
std::cout << "Largest clique is " << largest_clique << std::endl;
}
//decrement(set);
//increment(set);
i++;
}
return largest_clique;
}
示例3: convert_to_bitset
void SparseBipartiteGraph::convert_to_bitset(
boost::dynamic_bitset<>& bits) const {
std::vector < int > adj;
unsigned int n = getNumberOfNodes() / 2;
bits.resize(n * n);
for (int u = 0; u < n; u++) {
getNeighbors(u, adj);
for (std::vector<int>::iterator it = adj.begin(); it != adj.end();
++it) {
int v = *it;
unsigned int i = n * u + v - n;
bits[n * n - i - 1] = 1;
}
}
}
示例4: insert_if_exists
inline void insert_if_exists(boost::dynamic_bitset<>& cont, const boost::dynamic_bitset<> *other) {
if (other && !other->empty()) {
cont.resize(std::max(cont.size(), other->size()));
cont |= *other;
}
}
示例5: get_row
void DenseBipartiteGraph::get_row(int u, boost::dynamic_bitset<>& row) const {
row.resize(ncols);
for (int v = 0; v < ncols; v++) {
row[v] = has_edge(u, v);
}
}