当前位置: 首页>>代码示例>>C++>>正文


C++ dynamic_bitset::test方法代码示例

本文整理汇总了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;
}
开发者ID:IshanRastogi,项目名称:hhvm,代码行数:26,代码来源:cfg.cpp

示例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();
}
开发者ID:taohonker,项目名称:Ovito,代码行数:35,代码来源:BondsObject.cpp

示例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;
        }
    }
开发者ID:putnampp,项目名称:clotho,代码行数:26,代码来源:population_space_row_frequency_evaluator.hpp

示例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;
}
开发者ID:ryneches,项目名称:PhyloSift,代码行数:7,代码来源:readconciler.cpp

示例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;
        }
    }
开发者ID:putnampp,项目名称:clotho,代码行数:30,代码来源:row_grouped_frequency_evaluator.hpp

示例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 ) );
   }
 }
开发者ID:sterin,项目名称:cirkit,代码行数:8,代码来源:circuit_to_truth_table.cpp

示例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;
}
开发者ID:MorS25,项目名称:pcl-fuerte,代码行数:10,代码来源:normal_space.hpp

示例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;
 }
开发者ID:rpahl,项目名称:permory,代码行数:15,代码来源:recode.hpp

示例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);
  }
}
开发者ID:devmario,项目名称:hiphop-php,代码行数:12,代码来源:dce.cpp

示例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;
    }
开发者ID:41i,项目名称:hpx,代码行数:39,代码来源:remove_local_destinations.hpp

示例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();
	}
开发者ID:jf---,项目名称:IfcOpenShell,代码行数:19,代码来源:IfcWrite.cpp

示例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;
	}
}
开发者ID:anjin-viktor,项目名称:changeable-cipher,代码行数:24,代码来源:DisForm.cpp

示例13: getChildrenOnly

	/**
	 * Allow certain vertices to have only children, but no parents
	 */
	bool getChildrenOnly(const uint vertex) const { return _childrenOnly.test(vertex); }
开发者ID:YongkaiWu,项目名称:pcalg,代码行数:4,代码来源:greedy.hpp


注:本文中的boost::dynamic_bitset::test方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。