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


C++ boost::unordered_set类代码示例

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


在下文中一共展示了unordered_set类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: deep_equals

bool WRLDRecord::deep_equals(Record *master, RecordOp &read_self, RecordOp &read_master, boost::unordered_set<Record *> &identical_records)
    {
    //Precondition: equals has been run for these records and returned true
    //              all child records have been visited
    const WRLDRecord *master_wrld = (WRLDRecord *)master;

    if(CELLS.size() > master_wrld->CELLS.size())
        return false;

    if(CELL != NULL)
        {
        if(master_wrld->CELL != NULL)
            {
            if(identical_records.count(CELL) == 0)
                return false;
            }
        else
            return false;
        }

    for(uint32_t ListIndex = 0; ListIndex < CELLS.size(); ++ListIndex)
        if(identical_records.count(CELLS[ListIndex]) == 0)
                return false;
    return true;
    }
开发者ID:Dienes,项目名称:CBash,代码行数:25,代码来源:WRLDRecord.cpp

示例2: collect_vnodes

void VNode::collect_vnodes(boost::unordered_set<Node*>& nodes,uint& total)
{
	total++;
	boost::unordered_set<Node*>::iterator it = nodes.find(this);
	if(it==nodes.end())
		nodes.insert(this);
}
开发者ID:fqiang,项目名称:psmg,代码行数:7,代码来源:VNode.cpp

示例3: updateHelper

static void updateHelper (SLE::ref entry,
    boost::unordered_set< uint256 >& seen,
    boost::unordered_map< currencyIssuer_t, std::vector<OrderBook::pointer> >& destMap,
    boost::unordered_map< currencyIssuer_t, std::vector<OrderBook::pointer> >& sourceMap,
    boost::unordered_set< currencyIssuer_t >& XRPBooks,
    int& books)
{
    if ((entry->getType () == ltDIR_NODE) && (entry->isFieldPresent (sfExchangeRate)) &&
            (entry->getFieldH256 (sfRootIndex) == entry->getIndex()))
    {
        const uint160& ci = entry->getFieldH160 (sfTakerPaysCurrency);
        const uint160& co = entry->getFieldH160 (sfTakerGetsCurrency);
        const uint160& ii = entry->getFieldH160 (sfTakerPaysIssuer);
        const uint160& io = entry->getFieldH160 (sfTakerGetsIssuer);

        uint256 index = Ledger::getBookBase (ci, ii, co, io);

        if (seen.insert (index).second)
        {
            // VFALCO TODO Reduce the clunkiness of these parameter wrappers
            OrderBook::pointer book = boost::make_shared<OrderBook> (boost::cref (index),
                                      boost::cref (ci), boost::cref (co), boost::cref (ii), boost::cref (io));

            sourceMap[currencyIssuer_ct (ci, ii)].push_back (book);
            destMap[currencyIssuer_ct (co, io)].push_back (book);
            if (co.isZero())
                XRPBooks.insert(currencyIssuer_ct (ci, ii));
            ++books;
        }
    }
}
开发者ID:DaiLiRong,项目名称:rippled,代码行数:31,代码来源:OrderBookDB.cpp

示例4: registerDeferredObservers

    inline void ObservableSettings::registerDeferredObservers(boost::unordered_set<Observer*>& observers) {
        if (updatesDeferred())
	{
		QL_TRACE("adding " << observers.size() << " observers to the deferred list");
        	deferredObservers_.insert(observers.begin(), observers.end());
	}
    }
开发者ID:higgscc,项目名称:quantlib,代码行数:7,代码来源:observable.hpp

示例5: double

//calculates average of vectors
boost::unordered_map<string, double> Cluster::_centroid(boost::unordered_set<int>& cluster_list) {

  unordered_string_map centroid;

  int cluster_size = cluster_list.size();
  
  for (boost::unordered_set<int>::iterator it = cluster_list.begin(); it != cluster_list.end(); ++it) {

    //add each element of vector to centroid
    for (unordered_string_map::iterator ivec = doc_term_index[ *it ].begin(); ivec != doc_term_index[ *it ].end(); ++ivec) {
  
      //element (term) doesn't exist, we add it to the map
      if ( centroid.count ( ivec->first ) == 0) {
	//cout << "ivec second: " << ivec->second <<endl;
	//cout << "cluster_size: " << cluster_size <<endl;

	centroid.insert(unordered_string_map::value_type( ivec->first, double( (double)ivec->second / cluster_size ) ));
      }
      else {
	centroid[ivec->first] += double( ((double)ivec->second / cluster_size) );
      }

    }
  }    
  return centroid;
}
开发者ID:vergeman,项目名称:DeGustibus,代码行数:27,代码来源:cluster.cpp

示例6: distanceToCluster

float KernelKmeansClusterer::distanceToCluster(int sampleId,
		const boost::unordered_set<int>& clusterIdSet) {
	if (clusterIdSet.empty()) {
		return FLT_MAX;
	}
	// the sum of weight of the cluster
	float weightSum = 0.0f;
	// the sum of kernels from the sample to all samples in the cluster, multiplied by the weight
	float kernelSum = 0.0f;
	// the sum of kernels from each pair of samples in the cluster, multiplied by weights
	float kernelPairSum = 0.0f;
	for (boost::unordered_set<int>::const_iterator iter = clusterIdSet.begin();
			iter != clusterIdSet.end(); ++iter) {
		float weight = mWeightArray[*iter];
		weightSum += weight;
		float kernelResult = (*mpKernel)(sampleId, *iter);
		kernelSum += weight * kernelResult;
		for (boost::unordered_set<int>::const_iterator _iter =
				clusterIdSet.begin(); _iter != clusterIdSet.end(); ++_iter) {
			float _kernelResult = (*mpKernel)(*iter, *_iter);
			kernelPairSum += weight * mWeightArray[*_iter] * _kernelResult;
		}
	}
	float kernelSelf = (*mpKernel)(sampleId, sampleId);
	if (weightSum == 0.0f) {
		return FLT_MAX;
	}
	return kernelSelf - 2 * kernelSum / weightSum
			+ kernelPairSum / (weightSum * weightSum);
}
开发者ID:zixuanwang,项目名称:Research,代码行数:30,代码来源:KernelKmeansClusterer.cpp

示例7: dfs

void cluster_machine::dfs(const size_t curr, boost::unordered_set<size_t> &vis)
{
    vis.insert(curr);
    for (size_t e = first_[curr]; e != -1; e = next_[e]) {
        if ( vis.find(v_[e]) == vis.end() )
            dfs(v_[e], vis);
    }
}
开发者ID:wegatron,项目名称:embedded_thin_shell,代码行数:8,代码来源:cluster.cpp

示例8: get_live_object_names

Strings get_live_object_names() {
  IMP::Vector<std::string> ret;
  for (boost::unordered_set<Object*>::const_iterator it = live_.begin();
       it != live_.end(); ++it) {
    ret.push_back((*it)->get_name());
  }
  return ret;
}
开发者ID:AljGaber,项目名称:imp,代码行数:8,代码来源:base_static.cpp

示例9: make_pair

 inline std::pair<boost::unordered_set<boost::shared_ptr<Observable> >::iterator, bool>
 Observer::registerWith(const boost::shared_ptr<Observable>& h) {
     if (h) {
         h->registerObserver(this);
         return observables_.insert(h);
     }
     return std::make_pair(observables_.end(), false);
 }
开发者ID:higgscc,项目名称:quantlib,代码行数:8,代码来源:observable.hpp

示例10: serialize

		static void serialize(storage_type& s, const boost::unordered_set<T>& o)
			{
			uint32_t sz = o.size();
			s.serialize(sz);

			for (auto it = o.begin(), it_end = o.end(); it != it_end; ++it)
				s.serialize(*it);
			}
开发者ID:WantonSoup,项目名称:ufora,代码行数:8,代码来源:BoostContainerSerializers.hpp

示例11: AddReferencedMaterials

void MixMaterial::AddReferencedMaterials(boost::unordered_set<const Material *> &referencedMats) const {
	Material::AddReferencedMaterials(referencedMats);

	referencedMats.insert(matA);
	matA->AddReferencedMaterials(referencedMats);

	referencedMats.insert(matB);
	matB->AddReferencedMaterials(referencedMats);
}
开发者ID:yangzhengxing,项目名称:luxrender,代码行数:9,代码来源:mixmat.cpp

示例12: check_live_objects

IMPKERNEL_END_NAMESPACE
IMPKERNEL_BEGIN_INTERNAL_NAMESPACE
void check_live_objects() {
  for (boost::unordered_set<Object*>::const_iterator it = live_.begin();
       it != live_.end(); ++it) {
    IMP_USAGE_CHECK((*it)->get_ref_count() > 0,
                    "Object " << (*it)->get_name() << " is not ref counted.");
  }
}
开发者ID:AljGaber,项目名称:imp,代码行数:9,代码来源:base_static.cpp

示例13: print

void print(const std::string& outputFile, const boost::unordered_set<ZCTA>& zctas, const AdjacencySet& adjacencies) {
	std::ofstream out(outputFile.c_str());
	out << zctas.size() << std::endl;
	for (boost::unordered_set<ZCTA>::const_iterator i = zctas.cbegin(); i != zctas.cend(); ++i)
		out << i->id() << " " << i->interiorPoint().x().get_num() << " "
			<< i->interiorPoint().y().get_num() << std::endl;
	out << adjacencies.size() << std::endl;
	for (AdjacencySet::iterator i = adjacencies.begin(), end = adjacencies.end(); i != end; ++i)
		out << i->first.id() << " " << i->second.id() << std::endl;
}
开发者ID:DrSunglasses,项目名称:zcta,代码行数:10,代码来源:Printer.cpp

示例14: update

		void update(const key_type& inKey, const boost::unordered_set<value_type>& inValues)
			{
				{
				boost::unordered_set<value_type> curValues(getValues(inKey));
				for (auto it = curValues.begin(); it != curValues.end(); ++it)
					if (inValues.find(*it) == inValues.end())
						drop(inKey, *it);
				}

			insert(inKey, inValues);
			}
开发者ID:WantonSoup,项目名称:ufora,代码行数:11,代码来源:UnorderedTwoWaySetMap.hpp

示例15: Xeromyces_ReadScript

void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, boost::unordered_set<VfsPath>& Paths)
{
	// Check for a 'file' parameter
	CStrW file(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("file")).FromUTF8());

	// If there is a file specified, open and execute it
	if (!file.empty())
	{
		Paths.insert(file);
		try
		{
			m_ScriptInterface->LoadGlobalScriptFile(file);
		}
		catch (PSERROR_Scripting& e)
		{
			LOGERROR("GUI: Error executing script %s: %s", utf8_from_wstring(file), e.what());
		}
	}

	// If it has a directory attribute, read all JS files in that directory
	CStrW directory(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("directory")).FromUTF8());
	if (!directory.empty())
	{
		VfsPaths pathnames;
		vfs::GetPathnames(g_VFS, directory, L"*.js", pathnames);
		for (const VfsPath& path : pathnames)
		{
			// Only load new files (so when the insert succeeds)
			if (Paths.insert(path).second)
				try
				{
					m_ScriptInterface->LoadGlobalScriptFile(path);
				}
				catch (PSERROR_Scripting& e)
				{
					LOGERROR("GUI: Error executing script %s: %s", path.string8(), e.what());
				}
		}
	}

	// Execute inline scripts
	try
	{
		CStr code(Element.GetText());
		if (!code.empty())
			m_ScriptInterface->LoadGlobalScript(L"Some XML file", code.FromUTF8());
	}
	catch (PSERROR_Scripting& e)
	{
		LOGERROR("GUI: Error executing inline script: %s", e.what());
	}
}
开发者ID:2asoft,项目名称:0ad,代码行数:52,代码来源:CGUI.cpp


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