本文整理汇总了C++中boost::dynamic_bitset::test方法的典型用法代码示例。如果您正苦于以下问题:C++ dynamic_bitset::test方法的具体用法?C++ dynamic_bitset::test怎么用?C++ dynamic_bitset::test使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::dynamic_bitset
的用法示例。
在下文中一共展示了dynamic_bitset::test方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loopVisit
static bool loopVisit(const Block* b,
boost::dynamic_bitset<>& visited,
boost::dynamic_bitset<>& path) {
if (b == nullptr) return false;
auto const id = b->id();
// If we're revisiting a block in our current search, then we've
// found a backedge.
if (path.test(id)) return true;
// Otherwise if we're getting back to a block that's already been
// visited, but it hasn't been visited in this path, then we can
// prune this search.
if (visited.test(id)) return false;
visited.set(id);
path.set(id);
bool res = loopVisit(b->taken(), visited, path) ||
loopVisit(b->next(), visited, path);
path.set(id, false);
return res;
}
示例2: particlesDeleted
/******************************************************************************
* Remaps the bonds after some of the particles have been deleted.
* Dangling bonds are removed too.
******************************************************************************/
void BondsObject::particlesDeleted(const boost::dynamic_bitset<>& deletedParticlesMask)
{
// Build map that maps old particle indices to new indices.
std::vector<size_t> indexMap(deletedParticlesMask.size());
auto index = indexMap.begin();
size_t oldParticleCount = deletedParticlesMask.size();
size_t newParticleCount = 0;
for(size_t i = 0; i < deletedParticlesMask.size(); i++)
*index++ = deletedParticlesMask.test(i) ? std::numeric_limits<size_t>::max() : newParticleCount++;
auto result = modifiableStorage()->begin();
auto bond = modifiableStorage()->begin();
auto last = modifiableStorage()->end();
for(; bond != last; ++bond) {
// Remove invalid bonds.
if(bond->index1 >= oldParticleCount || bond->index2 >= oldParticleCount)
continue;
// Remove dangling bonds whose particles have gone.
if(deletedParticlesMask.test(bond->index1) || deletedParticlesMask.test(bond->index2))
continue;
// Keep but remap particle indices.
result->pbcShift = bond->pbcShift;
result->index1 = indexMap[bond->index1];
result->index2 = indexMap[bond->index2];
++result;
}
modifiableStorage()->erase(result, last);
changed();
}
示例3: operator
void operator()( space_type & ss, boost::dynamic_bitset<> & indices, result_type column_margin, result_type row_margin ) {
const unsigned int N = ss.haploid_genome_count();
for( unsigned int i = 0; i < N; ++i ) {
if( !indices.test(i) ) continue;
genome_pointer first = ss.begin_genome(i), last = ss.end_genome(i);
unsigned int j = 0;
unsigned int M = 0;
while( first != last ) {
block_type b = *first++;
unsigned int idx = j;
while( b ) {
idx += bit_walker_type::next_and_shift( b );
column_margin[ idx ]++;
++M;
}
j += bit_helper_type::BITS_PER_BLOCK;
}
row_margin[ i ] = M;
}
}
示例4: normalize_split
void normalize_split( boost::dynamic_bitset<>& split, const vector< vector< int > >& splitmap, int target_size ){
boost::dynamic_bitset<> newsplit( target_size );
for( int i=0; i<splitmap.size(); i++ )
for(int j=0; j<splitmap[i].size(); j++)
newsplit.set( splitmap[i][j], split.test(i) );
split = newsplit;
}
示例5: operator
void operator()( space_type & ss, boost::dynamic_bitset<> & indices, result_type column_margin, result_type row_margin ) {
typedef typename space_type::raw_block_pointer iterator;
size_type N = ss.row_count();
size_type i = 0;
while ( i < N ) {
if( !indices.test(i) ) {
++i;
continue;
}
iterator start = ss.begin_row(i);
iterator end = ss.end_row(i);
size_type j = 0, M = 0;
while( start != end ) {
block_type b = *start++;
while( b ) {
unsigned int b_idx = bit_walker_type::unset_next_index( b ) + j;
column_margin[ b_idx ] += 1;
++M;
}
j += bit_helper_type::BITS_PER_BLOCK;
}
row_margin[ i ] = M;
++i;
}
}
示例6: bitset_to_vector
void bitset_to_vector( binary_truth_table::cube_type& vec, const boost::dynamic_bitset<> number )
{
vec.clear();
for ( unsigned i = 0u; i < number.size(); ++i )
{
vec.push_back( number.test( i ) );
}
}
示例7:
template<typename PointT, typename NormalT> bool
pcl::NormalSpaceSampling<PointT, NormalT>::isEntireBinSampled (boost::dynamic_bitset<> &array, unsigned int start_index, unsigned int length)
{
bool status = true;
for (unsigned int i = start_index; i < start_index + length; i++)
{
status = status & array.test (i);
}
return status;
}
示例8:
//
// Derive index code from a bitset, that is, return a vector of all indices
// that are set in the bitset
//
std::vector<int> index_code(const boost::dynamic_bitset<>& b)
{
std::vector<int> v;
v.reserve(b.count());
for (int i=0; i<int(b.size()); ++i) {
if (b.test(i)) { //if (b[i] == 1)
v.push_back(i);
}
}
return v;
}
示例9: removeDeadInstructions
void removeDeadInstructions(Trace* trace, const boost::dynamic_bitset<>& live) {
auto &blocks = trace->getBlocks();
for (auto it = blocks.begin(), end = blocks.end(); it != end;) {
auto cur = it; ++it;
Block* block = *cur;
block->remove_if([&] (const IRInstruction& inst) {
assert(inst.getIId() < live.size());
return !live.test(inst.getIId());
});
if (block->empty()) blocks.erase(cur);
}
}
示例10:
// Returns true if at least one destination has been retained, i.e. one
// destination is remote. It returns false if all destinations have been
// local.
inline std::vector<naming::gid_type>::iterator
remove_local_destinations(std::vector<naming::gid_type>& gids,
std::vector<naming::address>& addrs,
boost::dynamic_bitset<> const& locals)
{
HPX_ASSERT(gids.size() == addrs.size());
std::vector<naming::gid_type>::iterator gids_it = gids.begin();
std::vector<naming::gid_type>::iterator gids_end = gids.end();
std::vector<naming::address>::iterator addrs_it = addrs.begin();
// gids_it = find_if(gids_it, gids_end, pred)
std::size_t i = 0;
for (/**/; gids_it != gids_end; ++gids_it, ++addrs_it)
{
if (locals.test(i++))
break;
}
if (gids_it == gids_end)
return gids_it;
// gids_next = remove_if(gids_it, gids_end, pred)
std::vector<naming::gid_type>::iterator gids_next = gids_it;
std::vector<naming::address>::iterator addrs_next = addrs_it;
for (++gids_it, ++addrs_it; gids_it != gids_end; ++gids_it, ++addrs_it)
{
if (!locals.test(i++))
{
*gids_next++ = std::move(*gids_it);
*addrs_next++ = std::move(*addrs_it);
}
}
return gids_next;
}
示例11: format_binary
std::string format_binary(const boost::dynamic_bitset<>& b) {
std::ostringstream oss;
oss.imbue(std::locale::classic());
oss.put('"');
oss << std::hex << std::setw(1);
unsigned c = b.size();
unsigned n = (4 - (c % 4)) & 3;
oss << n;
for (unsigned i = 0; i < c + n;) {
unsigned accum = 0;
for (int j = 0; j < 4; ++j, ++i) {
unsigned bit = i < n ? 0 : b.test(c - i + n - 1) ? 1 : 0;
accum |= bit << (3-j);
}
oss << accum;
}
oss.put('"');
return oss.str();
}
示例12: calculate
bool BDDCalculator::calculate(const boost::dynamic_bitset<> &varValues) const
{
if(!m_proot)
return false;
BDDCalculator::Node *pnode = m_proot -> m_pnode;
if(!pnode)
return false;
for(;;)
{
if(pnode -> m_fixTrue && pnode -> m_fixFalse)
{
if(varValues.test(pnode -> m_varId))
pnode = pnode -> m_fixTrue;
else
pnode = pnode -> m_fixFalse;
}
else
return pnode -> m_value;
}
}
示例13: getChildrenOnly
/**
* Allow certain vertices to have only children, but no parents
*/
bool getChildrenOnly(const uint vertex) const { return _childrenOnly.test(vertex); }