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


C++ multimap::size方法代码示例

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


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

示例1: readIntegerFile

void readIntegerFile(std::string inputFile, std::multimap<sampleType, int> &mapSample ){
  std::ifstream integerReader;
  std::string line;
  integerReader.open(inputFile, std::ios::in);
  int lineCounter = 0;  
  int diff = 1;
  while(std::getline(integerReader, line)){
    // read in the integer 
    std::istringstream iss(line);
    sampleType intSample(0);
    iss>>intSample; 
    // add it to the hash table 
    // mapSample[key] = data;
    // mapSample[intSample] = lineCounter;
    mapSample.insert(std::pair<sampleType, int>(intSample, lineCounter));

    lineCounter++;

    if((lineCounter - mapSample.size()) == diff){
      std::cout<<"At line: "<<lineCounter<<" , key: "<<intSample<<" is not inserted. "<<"Map size is: "<< mapSample.size()<<std::endl;
      diff++;
    }

  }// end of while 
  std::cout<<"The hash table size is: "<<mapSample.size()<<std::endl;
  std::cout<<"line counter is: "<<lineCounter<<std::endl;
  std::cout<<std::endl;
  std::cout<<std::endl;
  std::cout<<std::endl;
  //  std::cout<<"If the above two are not equal, then it means there are : "<<lineCounter<<std::endl;
} // end of reader 
开发者ID:wyqsnddd,项目名称:courseWork,代码行数:31,代码来源:two_sum_hash.cpp

示例2:

Plog::Plog(const std::multimap<double, Arrhenius>& rates)
    : logP_(-1000)
    , logP1_(1000)
    , logP2_(-1000)
    , rDeltaP_(-1.0)
{
    size_t j = 0;
    rates_.reserve(rates.size());
    // Insert intermediate pressures
    for (const auto& rate : rates) {
        double logp = std::log(rate.first);
        if (pressures_.empty() || pressures_.rbegin()->first != logp) {
            // starting a new group
            pressures_[logp] = {j, j+1};
        } else {
            // another rate expression at the same pressure
            pressures_[logp].second = j+1;
        }

        j++;
        rates_.push_back(rate.second);
    }

    // Duplicate the first and last groups to handle P < P_0 and P > P_N
    pressures_.insert({-1000.0, pressures_.begin()->second});
    pressures_.insert({1000.0, pressures_.rbegin()->second});
}
开发者ID:MrKingKong,项目名称:cantera,代码行数:27,代码来源:RxnRates.cpp

示例3: ltr_int_broadcast_pose

bool ltr_int_broadcast_pose(linuxtrack_full_pose_t &pose)
{
    pthread_mutex_lock(&send_mx);
    std::multimap<std::string, int>::iterator i;
    int res;
    bool checkSlaves = false;
    //Send updated pose to all clients
    //printf("Master: %g  %g  %g\n", pose.pose.raw_pitch, pose.pose.raw_yaw, pose.pose.raw_roll);
    for(i = slaves.begin(); i != slaves.end();) {
        res = ltr_int_send_data(i->second, &pose);
        if(res == -EPIPE) {
            ltr_int_log_message("Slave @socket %d left!\n", i->second);
            close(i->second);
            i->second = -1;
            slaves.erase(i++);
            checkSlaves = true;
        } else {
            ++i;
        }
    }
    if(checkSlaves && (slaves.size() == 0)) {
        no_slaves = true;
    }
    pthread_mutex_unlock(&send_mx);
    return true;
}
开发者ID:balthisar,项目名称:linuxtrack,代码行数:26,代码来源:ltr_srv_master.cpp

示例4:

std::vector<CIMSettings> InterwovenServers::GetDuplicateEntries(const std::map<CStdString, CIMSettings>& uniqueIntewovenServers, const std::multimap<CStdString, CIMSettings>& duplicateIntewovenServers)
{
	LOG_WS_FUNCTION_SCOPE();
	
	std::vector<CIMSettings> duplications;
	
	if(uniqueIntewovenServers.size() == duplicateIntewovenServers.size())
	{
		return duplications;
	}

	for(std::map<CStdString, CIMSettings>::const_iterator it = uniqueIntewovenServers.begin(); it != uniqueIntewovenServers.end(); ++it)
	{
		CStdString key = it->first;		
		
		if(duplicateIntewovenServers.count(key) == 1)
		{
			continue;
		}

		pair<multimap<CStdString, CIMSettings>::const_iterator, multimap<CStdString, CIMSettings>::const_iterator> equalRange = duplicateIntewovenServers.equal_range(key);
		for(multimap<CStdString, CIMSettings>::const_iterator it = equalRange.first; it != equalRange.second; ++it)
		{
			CIMSettings wsServer = it->second;
			wsServer.SetActionType(CIMSettings::REGISTRATION_ACTION_REMOVE);
			duplications.push_back(wsServer);		
		}
	}
	
	return duplications;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:31,代码来源:RegisteredInterwovenServersReader.cpp

示例5: defaultPriority

CServerDefinitions::CServerDefinitions() : defaultPriority( 0 )
{
	Console.PrintSectionBegin();
	Console << "Loading server scripts..." << myendl;
	Console << "   o Clearing AddMenuMap entries(" << g_mmapAddMenuMap.size() << ")" << myendl;
	g_mmapAddMenuMap.clear();
	ScriptListings.resize( NUM_DEFS );
	ReloadScriptObjects();
	Console.PrintSectionBegin();
}
开发者ID:bholtsclaw,项目名称:uox3,代码行数:10,代码来源:cServerDefinitions.cpp

示例6: it

inline void operator<< (object::with_zone& o, const std::multimap<K,V>& v)
{
	o.type = type::MAP;
	if(v.empty()) {
		o.via.map.ptr  = NULL;
		o.via.map.size = 0;
	} else {
		object_kv* p = (object_kv*)o.zone->malloc(sizeof(object_kv)*v.size());
		object_kv* const pend = p + v.size();
		o.via.map.ptr  = p;
		o.via.map.size = v.size();
		typename std::multimap<K,V>::const_iterator it(v.begin());
		do {
			p->key = object(it->first, o.zone);
			p->val = object(it->second, o.zone);
			++p;
			++it;
		} while(p < pend);
	}
}
开发者ID:RedSunCMX,项目名称:izenelib,代码行数:20,代码来源:map.hpp

示例7: findFab

bool findFab(std::multimap<int,int> pai, pair<int,int> couple)
{
    std::multimap<int,int>::iterator it = pai.end();

    if(pai.size() == 0) return false;

    for ( it = pai.equal_range(couple.first).first; it != pai.equal_range(couple.first).second; ++it)
      if( equals(couple, (*it)) )
          return true;

    return false;
}
开发者ID:linuxbandit,项目名称:BroadPhase,代码行数:12,代码来源:BroadPhase.cpp

示例8: MDFN_CallSettingsNotification

// TODO after a game is loaded, but should we?
void MDFN_CallSettingsNotification(void)
{
 for(unsigned int x = 0; x < CurrentSettings.size(); x++)
 {
  if(CurrentSettings[x].ChangeNotification)
  {
   // TODO, always call driver notification function, regardless of whether a game is loaded.
   if(MDFNGameInfo)
    CurrentSettings[x].ChangeNotification(CurrentSettings[x].name);
  }
 }
}
开发者ID:IcooN,项目名称:OpenEmu,代码行数:13,代码来源:settings.cpp

示例9: intersect

void intersect(int a, int b, const Point & I, std::vector<Segment> & segments, std::multimap<Point, int> & sweep, std::multimap<std::pair<double,int>, int,event_less> & events, bool print)
{
	//remove event of ending of old segment
	{
		int rem_end_events[2];
		rem_end_events[0] = a;
		rem_end_events[1] = b;
		for (int k = 0; k < 2; ++k)
		{
			std::pair< std::multimap<std::pair<double,int>, int,event_less>::iterator, std::multimap<std::pair<double,int>,int,event_less>::iterator > del = events.equal_range(std::make_pair(segments[rem_end_events[k]].end.x,SEG_END)); //get all events at position of the end
			bool flag = false;
			for (std::multimap<std::pair<double,int>, int,event_less>::iterator it = del.first; it != del.second; ++it) //search over all events
			{
				if (it->first.second == SEG_END && it->second == rem_end_events[k]) //event is end of segment and segment matches current
				{
					events.erase(it); //remove that segment
					flag = true;
					break; //do not expect any more
				}
			}
			if (!flag) std::cout << "Cannot find proper ending event for segment" << std::endl;
		}
	}
	//add new segment with intersection point up to end
	segments.push_back(Segment(I, segments[a].end));
	//add event of starting of new segment
	events.insert(std::make_pair(std::make_pair(I.x,SEG_START), (int)segments.size() - 1));
	//add event of ending of new segment
	events.insert(std::make_pair(std::make_pair(segments.back().end.x,SEG_END),(int)segments.size() - 1));
	//change ending point for current segment
	segments[a].end = I;
	//add event of ending of old segment
	events.insert(std::make_pair(std::make_pair(I.x,SEG_END), a));
	//add new segment with intersection point up to end
	segments.push_back(Segment(I, segments[b].end));
	//add event of starting of new segment
	events.insert(std::make_pair(std::make_pair(I.x,SEG_START), (int)segments.size() - 1));
	//add event of ending of new segment
	events.insert(std::make_pair(std::make_pair(segments.back().end.x,SEG_END), (int)segments.size() - 1));
	//change ending point for current segment
	segments[b].end = I;
	//add event of ending of old segment
	events.insert(std::make_pair(std::make_pair(I.x,SEG_END), b));
	if (print)
	{
		std::cout << "Number of events: " << events.size() << std::endl;
		for (std::multimap<std::pair<double, int>, int,event_less>::iterator it = events.begin(); it != events.end(); ++it)
			std::cout << "x: " << it->first.first << " type " << (it->first.second == SEG_START ? "start" : "end") << " segment " << it->second << std::endl;
	}
}
开发者ID:kirill-terekhov,项目名称:SweepLine,代码行数:50,代码来源:main.cpp

示例10: runTimedEvents

	void EventManager::runTimedEvents(TimePoint now) {
		//run all the events ready to run
		for (auto&& event : mEvents) {
			if (event->isReady(now)) {
				event->run();
			}
		}

		if (mSimpleTasks.size()) {
			auto top = mSimpleTasks.begin();
			if (now >= top->first) {
				top->second();
				mSimpleTasks.erase(top);
			}
		}
	}
开发者ID:Tomcc,项目名称:dojo,代码行数:16,代码来源:TimedEvent.cpp

示例11: GetAllDimensionsNames

void NetCDFFile::GetAllDimensionsNames(std::vector< std::string > &dimensionNames) const
{
    const std::multimap< std::string, netCDF::NcDim > dims = file.getDims();
    
    const std::size_t size = dims.size();
    
    dimensionNames.resize( size );
    
    std::size_t i = 0;
    for( std::multimap< std::string, netCDF::NcDim >::const_iterator it = dims.begin();
        it != dims.end();
        ++it )
    {
        dimensionNames[i] = (*it).first;
        i++;
    }
}
开发者ID:sofacoustics,项目名称:API_Cpp,代码行数:17,代码来源:SOFANcFile.cpp

示例12: GetAllVariablesNames

void NetCDFFile::GetAllVariablesNames(std::vector< std::string > &variableNames) const
{
    const std::multimap< std::string, netCDF::NcVar > vars = file.getVars();
    
    const std::size_t size = vars.size();
    
    variableNames.resize( size );
    
    std::size_t i = 0;
    for( std::multimap< std::string, netCDF::NcVar >::const_iterator it = vars.begin();
        it != vars.end();
        ++it )
    {
        variableNames[i]       = (*it).first;
        i++;
    }
}
开发者ID:sofacoustics,项目名称:API_Cpp,代码行数:17,代码来源:SOFANcFile.cpp

示例13: GetAllAttributesNames

void NetCDFFile::GetAllAttributesNames(std::vector< std::string > &attributeNames) const
{        
    const std::multimap< std::string, netCDF::NcGroupAtt > attributes = file.getAtts();
    
    const std::size_t size = attributes.size();
    
    attributeNames.resize( size );
    
    std::size_t i = 0;
    for( std::multimap< std::string, netCDF::NcGroupAtt >::const_iterator it = attributes.begin();
        it != attributes.end();
        ++it )
    {
        const std::string attributeName = (*it).first;
        
        attributeNames[ i ] = attributeName;
        i++;
    }
}
开发者ID:sofacoustics,项目名称:API_Cpp,代码行数:19,代码来源:SOFANcFile.cpp

示例14: PrettyPrint

 inline std::string PrettyPrint(const std::multimap<A, B, Compare, Allocator>& maptoprint, const bool add_delimiters=false, const std::string& separator=", ")
 {
     std::ostringstream strm;
     if (maptoprint.size() > 0)
     {
         if (add_delimiters)
         {
             strm << "{";
             typename std::multimap<A, B, Compare, Allocator>::const_iterator itr;
             for (itr = maptoprint.begin(); itr != maptoprint.end(); ++itr)
             {
                 std::pair<A, B> cur_pair(itr->first, itr->second);
                 if (itr != maptoprint.begin())
                 {
                     strm << separator << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
                 else
                 {
                     strm << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
             }
             strm << "}";
         }
         else
         {
             typename std::multimap<A, B, Compare, Allocator>::const_iterator itr;
             for (itr = maptoprint.begin(); itr != maptoprint.end(); ++itr)
             {
                 std::pair<A, B> cur_pair(itr->first, itr->second);
                 if (itr != maptoprint.begin())
                 {
                     strm << separator << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
                 else
                 {
                     strm << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
             }
         }
     }
     return strm.str();
 }
开发者ID:orthez,项目名称:arc_utilities,代码行数:42,代码来源:pretty_print.hpp

示例15:

std::multimap<float, std::vector<int> > HuffmanCoder::Pack(std::multimap<float, std::vector<int> >& map) {
    std::multimap<float, std::vector<int> > newMap;

    std::multimap<float, std::vector<int> >::iterator it = map.begin();
    for (unsigned int i = 0; i < map.size()/2; i++) {
        std::vector<int> newSymbolVector;
        float sumOfWeights = 0;

        for (int j = 0; j < 2; j++) {
            for (std::vector<int>::const_iterator itt = it->second.begin(); itt != it->second.end(); itt++) {
                newSymbolVector.push_back(*itt);
            }
            sumOfWeights += it->first;
            ++it;
        }

        newMap.insert(std::pair<float,std::vector<int> >(sumOfWeights, newSymbolVector));
    }
    return newMap;
}
开发者ID:KlewinS,项目名称:TPCHuffmanCoder,代码行数:20,代码来源:HuffmanCoder.cpp


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