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


C++ std::unordered_multimap类代码示例

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


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

示例1: strIsInHashTable

bool strIsInHashTable(RawString &str, std::hash<std::string> &strHash,
    std::unordered_multimap<u32, StringTableNode> &stringTable)
{
    u32 hash = strHash(str);
    int numMatching = stringTable.count(hash);
    if ( numMatching == 1 )
    { // Should guarentee that you can find at least one entry
        StringTableNode &node = stringTable.find(hash)->second;
        if ( node.string.compare(str) == 0 )
            return true;
    }
    else if ( numMatching > 1 )
    {
        u32 currLowest = 0;
        bool success = false;
        auto range = stringTable.equal_range(hash);
        for ( auto it = range.first; it != range.second; it ++ )
        {
            StringTableNode &node = it->second;
            if ( node.string.compare(str) == 0 )
            {
                if ( success == false ) // If no matches have previously been found
                {
                    currLowest = node.stringNum;
                    success = true;
                }
                else if ( node.stringNum < currLowest ) // If matches have previously been found
                    currLowest = node.stringNum; // Replace if stringNum < previous stringNum
            }
        }
        return success;
    }
    return false; // No matches
}
开发者ID:heinermann,项目名称:Chkdraft,代码行数:34,代码来源:StringTableNode.cpp

示例2: f_unordered_multimap

void f_unordered_multimap() {
  std::unordered_multimap<int, int> C;
  std::unordered_multimap<int, int>::iterator UMMapI1 = C.begin();
  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
  // CHECK-FIXES: auto UMMapI1 = C.begin();

  const std::unordered_multimap<int, int> D;
  std::unordered_multimap<int, int>::const_iterator UMMapI2 = D.begin();
  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
  // CHECK-FIXES: auto UMMapI2 = D.begin();
}
开发者ID:GameFusion,项目名称:clang-tools-extra,代码行数:11,代码来源:modernize-use-auto-iterator.cpp

示例3: get_keypoint_strokes

PyArrayObject* get_keypoint_strokes(int keypointId, int instance)
{
	if(keypointsPixels.size() > 0)
	{
		std::pair <std::unordered_multimap<int,std::pair<int, int> >::iterator, std::unordered_multimap<int,std::pair<int, int>>::iterator> ret;
		ret = keypointsPixels.equal_range(keypoints[keypointId].class_id);

		npy_intp size_pts[2];
		size_pts[0] = std::distance(ret.first, ret.second);
		size_pts[1] = 2;
		PyArrayObject* out = (PyArrayObject *) PyArray_SimpleNew( 2, size_pts, NPY_OBJECT );
		int strokesCount = 0;

		for (std::unordered_multimap<int,std::pair<int, int> >::iterator it=ret.first; it!=ret.second; it++)
		{
			char* ptr = (char*) PyArray_GETPTR2(out, strokesCount, 0);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(it->second.first));
			ptr = (char*) PyArray_GETPTR2(out, strokesCount, 1);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(it->second.second));
			strokesCount++;
		}
		return out;

	}

	std::vector<std::vector<cv::Ptr<StrokeDir> > >& strokes = instances[instance].segmenter->keypointStrokes[keypointId];
	npy_intp size_pts[2];
	int strokesCount = 0;
	for( size_t i = 0; i < strokes.size(); i++ )
	{
		strokesCount += strokes[i].size();
	}
	size_pts[0] = strokesCount;

	size_pts[1] = 4;
	PyArrayObject* out = (PyArrayObject *) PyArray_SimpleNew( 2, size_pts, NPY_OBJECT );
	strokesCount = 0;
	for( size_t i = 0; i < strokes.size(); i++ )
	{
		for( size_t j = 0; j < strokes[i].size(); j++ )
		{
			char* ptr = (char*) PyArray_GETPTR2(out, strokesCount, 0);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->center.x));
			ptr = (char*) PyArray_GETPTR2(out, strokesCount, 1);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->center.y));
			ptr = (char*) PyArray_GETPTR2(out, strokesCount, 2);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->direction.x));
			ptr = (char*) PyArray_GETPTR2(out, strokesCount, 3);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->direction.y));
			strokesCount++;
		}
	}
	return out;
}
开发者ID:shannonyu,项目名称:FASText,代码行数:54,代码来源:pyFastTextG.cpp

示例4:

	bool DataVariantTextPlain::parse
	(
		const Socket &sock,
		const std::chrono::milliseconds &timeout,
		std::string &str,
		const size_t leftBytes,
		const std::unordered_map<std::string, std::string> &params,
		std::unordered_multimap<std::string, std::string> &data,
		std::unordered_multimap<std::string, FileIncoming> &files
	)
	{
		if (str.empty() )
		{
			return true;
		}

		for (size_t var_pos = 0, var_end = 0; std::string::npos != var_end; var_pos = var_end + 1)
		{
			// Поиск следующего параметра
			var_end = str.find('&', var_pos);

			// Поиск значения параметра
			size_t delimiter = str.find('=', var_pos);

			if (delimiter >= var_end)
			{
				// Получить имя параметра
				std::string var_name = str.substr(var_pos, std::string::npos != var_end ? var_end - var_pos : std::string::npos);

				// Сохранить параметр с пустым значением
				data.emplace(std::move(var_name), "");
			}
			else
			{
				// Получить имя параметра
				std::string var_name = str.substr(var_pos, delimiter - var_pos);

				++delimiter;

				// Получить значение параметра
				std::string var_value = str.substr(delimiter, std::string::npos != var_end ? var_end - delimiter : std::string::npos);

				// Сохранить параметр и значение
				data.emplace(std::move(var_name), std::move(var_value) );
			}
		}

		str.clear();

		return true;
	}
开发者ID:changbiao,项目名称:httpserver,代码行数:51,代码来源:DataVariantTextPlain.cpp

示例5: rawFilesInfoToFilesIncoming

	void rawFilesInfoToFilesIncoming(std::unordered_multimap<std::string, HttpServer::FileIncoming> &map, const Utils::raw_fileinfo raw[], const size_t count)
	{
		for (size_t i = 0; i < count; ++i)
		{
			map.emplace(raw[i].key ? raw[i].key : "", HttpServer::FileIncoming(raw[i].file_name, raw[i].file_type, raw[i].file_size) );
		}
	}
开发者ID:chardash,项目名称:httpserver,代码行数:7,代码来源:Utils.cpp

示例6: calmaxBW

//calculate the given dynamical-network's maxminum B and its corresponding w
std::pair<int,double> calmaxBW(std::unordered_multimap<int,std::pair<int,int>> &SN)
{
  int maxB = 0,temp,attractor = 0;
  double Wn;
  for(auto it = SN.begin(); it != SN.end(); it++){
    if(it->first == it->second.first){
      temp = calBRec(SN,it->second.first);
      if(temp > maxB){
	maxB = temp;
	attractor = it->first;//main attractor
      }
    }
  }
  Wn = calWRec(SN,attractor,1,0);
  return std::make_pair(maxB,Wn/maxB);
}
开发者ID:galow,项目名称:checkpoint,代码行数:17,代码来源:checkpoint.cpp

示例7: findMaxBW

//find the maximum B:basin for a given directed network
std::pair<int,double> findMaxBW(std::unordered_multimap<int,std::pair<int,int>> &SN,double *TF)
{
  int maxB = 0,temp,attractor = 0;
  double Wn;
  for(auto it = SN.begin(); it != SN.end(); it++){
    /**!!!!!!!!!!!your must change attractor!!!!!!!!**/
    if(it->first == it->second.first && it->first == 76){
      temp = findMaxBRec(SN,it->second.first,TF);
      if(temp > maxB){
	maxB = temp;
	attractor = it->first;//main attractor
      }
    }
  }
  Wn = calWRec(SN,attractor,1,0);
  return std::make_pair(maxB,Wn/maxB);
}
开发者ID:galow,项目名称:checkpoint-2013-07-20,代码行数:18,代码来源:checkpoint.cpp

示例8: packFilesIncoming

	void packFilesIncoming(
		std::vector<char> &buf,
		const std::unordered_multimap<std::string, Transfer::FileIncoming> &map
	) {
		packNumber(buf, map.size() );

		for (auto it = map.cbegin(); map.cend() != it; ++it) {
			packString(buf, it->first);

			const Transfer::FileIncoming &file = it->second;

			packString(buf, file.getTmpName() );
			packString(buf, file.getName() );
			packString(buf, file.getType() );
			packNumber(buf, file.getSize() );
		}
	}
开发者ID:awwit,项目名称:httpserver,代码行数:17,代码来源:FileIncoming.cpp

示例9: operator

 void operator()(msgpack::object::with_zone& o, const std::unordered_multimap<K, V, Hash, Compare, Alloc>& v) const {
     o.type = msgpack::type::MAP;
     if(v.empty()) {
         o.via.map.ptr  = nullptr;
         o.via.map.size = 0;
     } else {
         uint32_t size = checked_get_container_size(v.size());
         msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
         msgpack::object_kv* const pend = p + size;
         o.via.map.ptr  = p;
         o.via.map.size = size;
         typename std::unordered_multimap<K, V, Hash, Compare, Alloc>::const_iterator it(v.begin());
         do {
             p->key = msgpack::object(it->first, o.zone);
             p->val = msgpack::object(it->second, o.zone);
             ++p;
             ++it;
         } while(p < pend);
     }
 }
开发者ID:DarumasLegs,项目名称:volumedriver,代码行数:20,代码来源:unordered_map.hpp

示例10: calDeltaBRec

//store every state-network node's B in "TF_B"
int calDeltaBRec(std::unordered_multimap<int,std::pair<int,int>> &SN,int start,double *TF_B)
{
  int b = 1,temp;
  auto its = SN.equal_range(start);
  for (auto it = its.first; it != its.second; ++it)
    if(it->first != it->second.first){
      temp = calDeltaBRec(SN,it->second.first,TF_B);
      b += temp;
    }
  TF_B[start] = b;
  return b;
}
开发者ID:galow,项目名称:checkpoint,代码行数:13,代码来源:checkpoint.cpp

示例11: calBRec

//calculate B recursion function
int calBRec(std::unordered_multimap<int,std::pair<int,int>> &SN,int start)
{
  int b = 1,temp;
  auto its = SN.equal_range(start);
  for (auto it = its.first; it != its.second; ++it)
    if(it->first != it->second.first){
      temp = calBRec(SN,it->second.first);
      b += temp;
      it->second.second = temp;//traffic flow
    }
  return b;
}
开发者ID:galow,项目名称:checkpoint,代码行数:13,代码来源:checkpoint.cpp

示例12: calDeltaDRec

//store every state-network node's D in "TF_D"
int calDeltaDRec(std::unordered_multimap<int,std::pair<int,int>> &SN,int start,double *TF_D)
{
  int d = 0,temp;
  auto its = SN.equal_range(start);
  for (auto it = its.first; it != its.second; ++it)
    if(it->first != it->second.first){
      temp = calDeltaDRec(SN,it->second.first,TF_D);
      d += 1;
      it->second.second = temp;//traffic flow
    }
  TF_D[start] = d;
  return d;
}
开发者ID:galow,项目名称:checkpoint,代码行数:14,代码来源:checkpoint.cpp

示例13: filesIncomingToRawFilesInfo

	void filesIncomingToRawFilesInfo(Utils::raw_fileinfo *raw[], const std::unordered_multimap<std::string, HttpServer::FileIncoming> &map)
	{
		if (raw && map.size() )
		{
			raw_fileinfo *arr = new raw_fileinfo[map.size()];

			*raw = arr;

			size_t i = 0;

			for (auto it = map.cbegin(); map.cend() != it; ++it, ++i)
			{
				arr[i].key = stlStringToPChar(it->first);

				const HttpServer::FileIncoming &file = it->second;

				arr[i].file_name = stlStringToPChar(file.getName() );
				arr[i].file_type = stlStringToPChar(file.getType() );
				arr[i].file_size = file.getSize();
			}
		}
	}
开发者ID:chardash,项目名称:httpserver,代码行数:22,代码来源:Utils.cpp

示例14: calWRec

//calculate the <Wn>,and store the W for each attractor
double calWRec(std::unordered_multimap<int,std::pair<int,int>> &SN,int start,int L,int total_trafic)
{
  int total_traffic2;
  double w = 0;
  auto its = SN.equal_range(start);
  for (auto it = its.first; it != its.second; ++it)
    if(it->first != it->second.first){
      total_traffic2 = total_trafic + it->second.second; //total traffic flow from it->second.second to the attractor
      w += (double)total_traffic2/L + calWRec(SN,it->second.first,L+1,total_traffic2);
    }
  //store the traffic flow!!!!this is not traffic flow!!!!!
  //TF[start] = w;
  return w;
}
开发者ID:galow,项目名称:checkpoint-2013-07-20,代码行数:15,代码来源:checkpoint.cpp

示例15: PreFullReleaseModel

void PreFullReleaseModel(int streamingIdx)
{
	int drawblDict = *(int*)0xF272E4;

	if (streamingIdx >= GetTypeStart(drawblDict) && streamingIdx <= GetTypeEnd(drawblDict))
	{
		int dict = streamingIdx - GetTypeStart(drawblDict);

		auto pair = m_dependencyDrawableDicts.equal_range(dict);

		for (auto it = pair.first; it != pair.second; it++)
		{
			if (it->second->HasInstance())
			{
				//trace("releasing dict %s (0x%08x) for a full release because *reasons*\n", GetStreamName(dict, *(int*)0xF272E4).c_str(), it->second->GetModelHash());

				it->second->RemoveInstance();
			}
		}

		//m_dependencyDrawableDicts.erase(dict);

		auto entPair = m_dependencyDictEnts.equal_range(dict);

		for (auto it = entPair.first; it != entPair.second; it++)
		{
			//trace("also destroying model for dict %s\n", GetStreamName(dict, *(int*)0xF272E4).c_str());

			it->second->DestroyModel();
		}

		m_dependencyDictEnts.erase(dict);
	}
}
开发者ID:ByModzMaster,项目名称:client,代码行数:34,代码来源:HookModelInfoParents.cpp


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