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


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

本文整理汇总了C++中boost::dynamic_bitset::set方法的典型用法代码示例。如果您正苦于以下问题:C++ dynamic_bitset::set方法的具体用法?C++ dynamic_bitset::set怎么用?C++ dynamic_bitset::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::dynamic_bitset的用法示例。


在下文中一共展示了dynamic_bitset::set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: init_migrate_done_set

 void table_manager::init_migrate_done_set(boost::dynamic_bitset<> &migrate_done_set, const vector<uint64_t> &current_state_table)
 {
    int bucket_number = 0;
    for (size_t i=0; i<current_state_table.size(); i+=this->copy_count) {
       bucket_number = (int)current_state_table[i++]; // skip the bucket_number
       bool has_migrated = false;
       for (size_t j=0; j<this->copy_count; ++j) {
          if (current_state_table[i+j] != server_table[bucket_number + j * this->bucket_count]) {
             has_migrated = true;
             break;
          }
       }
       if (has_migrated) {
          migrate_done_set.set(bucket_number, true);
          log_debug("bucket[%d] has migrated");
       }
    }
 }
开发者ID:IsCaster,项目名称:tair-rdb,代码行数:18,代码来源:table_manager.cpp

示例3: mark

 bool mark (unsigned key)
 {
     if (flags_[key]) return false;
     flags_.set(key);
     return true;
 }
开发者ID:andrewdefries,项目名称:chemmine-ei,代码行数:6,代码来源:mplsh.cpp

示例4: setChildrenOnly

	void setChildrenOnly(const uint vertex, const bool setting) { _childrenOnly.set(vertex, setting); }
开发者ID:YongkaiWu,项目名称:pcalg,代码行数:1,代码来源:greedy.hpp

示例5: if

std::vector<unsigned int> generateBondHashes(const ROMol &mol, boost::dynamic_bitset<>& atomsInPath,
    const std::vector<const Bond *>& bondCache,
    const std::vector<short>& isQueryBond,
    const PATH_TYPE &path, bool useBondOrder,
    std::vector<boost::uint32_t> *atomInvariants){

  PRECONDITION(!atomInvariants || atomInvariants->size() >= mol.getNumAtoms(),
               "bad atomInvariants size");

  std::vector<unsigned int> bondHashes;
  atomsInPath.reset();
  bool queryInPath=false;
  std::vector<unsigned int> atomDegrees(mol.getNumAtoms(),0);
  for(unsigned int i=0;i<path.size() && !queryInPath;++i){
    const Bond *bi = bondCache[path[i]];
    atomDegrees[bi->getBeginAtomIdx()]++;
    atomDegrees[bi->getEndAtomIdx()]++;
    atomsInPath.set(bi->getBeginAtomIdx());
    atomsInPath.set(bi->getEndAtomIdx());
    if(isQueryBond[path[i]]) queryInPath=true;
  }
  if(queryInPath){
    return bondHashes;
  }

  // -----------------
  // calculate the bond hashes:
  std::vector<unsigned int> bondNbrs(path.size(),0);
  bondHashes.reserve(path.size()+1);

  for(unsigned int i=0;i<path.size();++i){
    const Bond *bi = bondCache[path[i]];
#ifdef REPORT_FP_STATS
        if (std::find(atomsToUse.begin(), atomsToUse.end(),
                      bi->getBeginAtomIdx()) == atomsToUse.end()) {
          atomsToUse.push_back(bi->getBeginAtomIdx());
        }
        if (std::find(atomsToUse.begin(), atomsToUse.end(),
                      bi->getEndAtomIdx()) == atomsToUse.end()) {
          atomsToUse.push_back(bi->getEndAtomIdx());
        }
#endif
    for(unsigned int j=i+1;j<path.size();++j){
      const Bond *bj = bondCache[path[j]];
      if(bi->getBeginAtomIdx()==bj->getBeginAtomIdx() ||
          bi->getBeginAtomIdx()==bj->getEndAtomIdx() ||
          bi->getEndAtomIdx()==bj->getBeginAtomIdx() ||
          bi->getEndAtomIdx()==bj->getEndAtomIdx() ){
        ++bondNbrs[i];
        ++bondNbrs[j];
      }
    }
#ifdef VERBOSE_FINGERPRINTING
        std::cerr << "   bond(" << i << "):" << bondNbrs[i] << std::endl;
#endif
    // we have the count of neighbors for bond bi, compute its hash:
    unsigned int a1Hash = (*atomInvariants)[bi->getBeginAtomIdx()];
    unsigned int a2Hash = (*atomInvariants)[bi->getEndAtomIdx()];
    unsigned int deg1=atomDegrees[bi->getBeginAtomIdx()];
    unsigned int deg2=atomDegrees[bi->getEndAtomIdx()];
    if(a1Hash<a2Hash){
      std::swap(a1Hash,a2Hash);
      std::swap(deg1,deg2);
    }
    else if(a1Hash==a2Hash && deg1<deg2){
      std::swap(deg1,deg2);
    }
    unsigned int bondHash=1;
    if(useBondOrder){
      if(bi->getIsAromatic() || bi->getBondType()==Bond::AROMATIC){
        // makes sure aromatic bonds always hash as aromatic
        bondHash = Bond::AROMATIC;
      }
      else {
        bondHash = bi->getBondType();
      }
    }
    boost::uint32_t ourHash=bondNbrs[i];
    gboost::hash_combine(ourHash,bondHash);
    gboost::hash_combine(ourHash,a1Hash);
    gboost::hash_combine(ourHash,deg1);
    gboost::hash_combine(ourHash,a2Hash);
    gboost::hash_combine(ourHash,deg2);
    bondHashes.push_back(ourHash);
    //std::cerr<<"    "<<bi->getIdx()<<" "<<a1Hash<<"("<<deg1<<")"<<"-"<<a2Hash<<"("<<deg2<<")"<<" "<<bondHash<<" -> "<<ourHash<<std::endl;
  }
  return bondHashes;
}
开发者ID:Richard-Hall,项目名称:rdkit,代码行数:88,代码来源:Fingerprints.cpp

示例6: filterParticles

/******************************************************************************
* Performs the actual rejection of particles.
******************************************************************************/
size_t SliceModifier::filterParticles(boost::dynamic_bitset<>& mask, TimePoint time, TimeInterval& validityInterval)
{
	// Get the required input properties.
	ParticlePropertyObject* const posProperty = expectStandardProperty(ParticleProperty::PositionProperty);
	ParticlePropertyObject* const selProperty = applyToSelection() ? inputStandardProperty(ParticleProperty::SelectionProperty) : nullptr;
	OVITO_ASSERT(posProperty->size() == mask.size());
	OVITO_ASSERT(!selProperty || selProperty->size() == mask.size());

	FloatType sliceWidth = 0;
	if(_widthCtrl) sliceWidth = _widthCtrl->getFloatValue(time, validityInterval);
	sliceWidth *= 0.5;

	Plane3 plane = slicingPlane(time, validityInterval);

	size_t na = 0;
	boost::dynamic_bitset<>::size_type i = 0;
	const Point3* p = posProperty->constDataPoint3();
	const Point3* p_end = p + posProperty->size();

	if(sliceWidth <= 0) {
		if(selProperty) {
			const int* s = selProperty->constDataInt();
			for(; p != p_end; ++p, ++s, ++i) {
				if(*s && plane.pointDistance(*p) > 0) {
					mask.set(i);
					na++;
				}
				else mask.reset(i);
			}
		}
		else {
			for(; p != p_end; ++p, ++i) {
				if(plane.pointDistance(*p) > 0) {
					mask.set(i);
					na++;
				}
				else mask.reset(i);
			}
		}
	}
	else {
		bool invert = inverse();
		if(selProperty) {
			const int* s = selProperty->constDataInt();
			for(; p != p_end; ++p, ++s, ++i) {
				if(*s && invert == (plane.classifyPoint(*p, sliceWidth) == 0)) {
					mask.set(i);
					na++;
				}
				else mask.reset(i);
			}
		}
		else {
			for(; p != p_end; ++p, ++i) {
				if(invert == (plane.classifyPoint(*p, sliceWidth) == 0)) {
					mask.set(i);
					na++;
				}
				else mask.reset(i);
			}
		}
	}
	return na;
}
开发者ID:bitzhuwei,项目名称:OVITO_sureface,代码行数:67,代码来源:SliceModifier.cpp


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