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


C++ map_type::end方法代码示例

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


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

示例1: compare

			static bool compare(map_type const & MA, map_type const & MB)
			{
				std::vector < std::pair<std::string,std::string> > SA, SB;
				for ( typename map_type::const_iterator ita = MA.begin(); ita != MA.end(); ++ita )
					SA.push_back(std::pair<std::string,std::string>(ita->first,ita->second));
				for ( typename map_type::const_iterator ita = MB.begin(); ita != MB.end(); ++ita )
					SB.push_back(std::pair<std::string,std::string>(ita->first,ita->second));
				std::sort(SA.begin(),SA.end());
				std::sort(SB.begin(),SB.end());
				
				uint64_t ia = 0, ib = 0;
				
				for ( ; ia != SA.size() && ib != SB.size() ; ++ia, ++ib )
					if ( SA[ia] != SB[ib] )
					{
						#if 0
						std::cerr << printPair(SA[ia]) << " != " << printPair(SB[ib]) << std::endl;
						
						for ( uint64_t i = 0; i < SA.size(); ++i )
							std::cerr << SA[i].first << ";";
						std::cerr << MA.size();
						std::cerr << std::endl;
						for ( uint64_t i = 0; i < SB.size(); ++i )
							std::cerr << SB[i].first << ";";
						std::cerr << MB.size();
						std::cerr << std::endl;
						#endif
						
						return SA[ia] < SB[ib];
					}

				return ia < ib;
			}
开发者ID:allisonheath,项目名称:public-workflows,代码行数:33,代码来源:StringMapCompare.hpp

示例2: main

int main(int argc, const char** argv)
{
   std::string text;
   for(int i = 1; i < argc; ++i)
   {
      cout << "Processing file " << argv[i] << endl;
      std::ifstream fs(argv[i]);
      load_file(text, fs);
      fs.close();
      // construct our iterators:
      boost::sregex_iterator m1(text.begin(), text.end(), expression);
      boost::sregex_iterator m2;
      std::for_each(m1, m2, &regex_callback);
      // copy results:
      cout << class_index.size() << " matches found" << endl;
      map_type::iterator c, d;
      c = class_index.begin();
      d = class_index.end();
      while(c != d)
      {
         cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
         ++c;
      }
      class_index.erase(class_index.begin(), class_index.end());
   }
   return 0;
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:27,代码来源:regex_iterator_example.cpp

示例3: find_unreachable_objects_impl

static void find_unreachable_objects_impl(map_type const & m, map2_type & m2)
{
    // scan objects for shared_ptr members, compute internal counts

    {
        std::cout << "... " << m.size() << " objects in m.\n";

        for(map_type::const_iterator i = m.begin(); i != m.end(); ++i)
        {
            abt_boost::detail::sp_counted_base const * p = static_cast<abt_boost::detail::sp_counted_base const *>(i->first);

            BOOST_ASSERT(p->use_count() != 0); // there should be no inactive counts in the map

            m2[ i->first ];

            scan_and_count(i->second.first, i->second.second, m, m2);
        }

        std::cout << "... " << m2.size() << " objects in m2.\n";
    }

    // mark reachable objects

    {
        open_type open;

        for(map2_type::iterator i = m2.begin(); i != m2.end(); ++i)
        {
            abt_boost::detail::sp_counted_base const * p = static_cast<abt_boost::detail::sp_counted_base const *>(i->first);
            if(p->use_count() != i->second) open.push_back(p);
        }

        std::cout << "... " << open.size() << " objects in open.\n";

        for(open_type::iterator j = open.begin(); j != open.end(); ++j)
        {
            m2.erase(*j);
        }

        while(!open.empty())
        {
            void const * p = open.front();
            open.pop_front();

            map_type::const_iterator i = m.find(p);
            BOOST_ASSERT(i != m.end());

            scan_and_mark(i->second.first, i->second.second, m2, open);
        }
    }

    // m2 now contains the unreachable objects
}
开发者ID:jbruestle,项目名称:aggregate_btree,代码行数:53,代码来源:sp_collector.cpp

示例4: if

inline std::error_category const & to_std_category( boost::system::error_category const & cat )
{
    if( cat == boost::system::system_category() )
    {
        static const std_category system_instance( &cat, 0x1F4D7 );
        return system_instance;
    }
    else if( cat == boost::system::generic_category() )
    {
        static const std_category generic_instance( &cat, 0x1F4D3 );
        return generic_instance;
    }
    else
    {
        typedef std::map< boost::system::error_category const *, std::unique_ptr<std_category>, cat_ptr_less > map_type;

        static map_type map_;
        static std::mutex map_mx_;

        std::lock_guard<std::mutex> guard( map_mx_ );

        map_type::iterator i = map_.find( &cat );

        if( i == map_.end() )
        {
            std::unique_ptr<std_category> p( new std_category( &cat, 0 ) );

            std::pair<map_type::iterator, bool> r = map_.insert( map_type::value_type( &cat, std::move( p ) ) );

            i = r.first;
        }

        return *i->second;
    }
}
开发者ID:boostorg,项目名称:system,代码行数:35,代码来源:std_interoperability.hpp

示例5: guard

        inline const message::factory *get_factory(message_type type) const
        {
            lock guard(m);

            auto it = factories.find(type);
            return (it == factories.end()) ? nullptr : it->value;
        }
开发者ID:stonedcoldsoup,项目名称:fungus_libs,代码行数:7,代码来源:message.cpp

示例6: if

void *runner(void *f)
{
    string tmp = "", content = *(string *)f;            //將傳過來的指標轉成string

    for (int i = 0; i < content.length()+1; ++i) {
        if(content[i]=='\'' && tmp!="" &&((content[i+1]>='a' && content[i+1]<='z') || (content[i+1]>='A' && content[i+1]<='Z')) )   // 單引號的前後為英文單字的
        {
            tmp += content[i];
            continue;
        }

        if(content[i]>='a' && content[i] <='z') 
            tmp += content[i];
        else if(content[i] >='A' && content[i] <= 'Z')
            tmp += tolower(content[i]);
        else if(tmp != "")
        {
            pthread_mutex_lock(&mutex);         //鎖

            /* critical section */
            iter = m.find(tmp);                 //搜尋
            if(iter != m.end())
                iter->second++;                 //資料重複,所以將次數+1
            else
                m.insert(map_type::value_type(tmp,1));          //插入資料

            pthread_mutex_unlock(&mutex);       //解鎖
            tmp = "";
        }
    }

    pthread_exit(0);                            //結束thread
}
开发者ID:tim124058,项目名称:pthread,代码行数:33,代码来源:WordAnal.cpp

示例7: clause

 //! conversion to clause
 clause_type clause() const {
     clause_type C;
     const iterator pa_end = pa.end();
     for (iterator i = pa.begin(); i != pa_end; ++i)
         C.ls.insert(literal_type(i->first, i->second));
     return C;
 }
开发者ID:OKullmann,项目名称:oklibrary,代码行数:8,代码来源:PartAssign.hpp

示例8: sum

 /** Compute the sum of all the elements
  * Implements compensated summation
  */
 double sum() {
     double s=0.;
     for (map_type::iterator it=map.begin(),itend=map.end();it!=itend;++it) {
         s += it->second;
     }
     return s;
 }
开发者ID:kkloste,项目名称:hkgrow,代码行数:10,代码来源:hktest_mex.cpp

示例9: get

inline class_id class_id_map::get(type_id const& type) const
{
    map_type::const_iterator i = m_classes.find(type);
    if (i == m_classes.end() || i->second >= local_id_base)
        return unknown_class;
    return i->second;
}
开发者ID:neomantra,项目名称:luabind,代码行数:7,代码来源:inheritance.hpp

示例10:

Dispatch::Handler Dispatch::code2handler( Message::type_t type )
{
	typedef std::map<Message::type_t, Handler> map_type;
	static map_type handlers;
	if ( handlers.empty() ) {
		using namespace MessageTypes;
		handlers[ NameQuery ] = &Dispatch::namequery_handler;
		handlers[ NameReply ] = &Dispatch::namereply_handler;
		handlers[ Opponentname ] = &Dispatch::opponentname_handler;
		handlers[ Receive ] = &Dispatch::receive_handler;
		handlers[ Invalidmove ] = &Dispatch::invalidmove_handler;
		handlers[ Inform ] = &Dispatch::inform_handler;
		handlers[ Status ] = &Dispatch::status_handler;
		handlers[ Points ] = &Dispatch::points_handler;
		handlers[ PlayQuery ] = &Dispatch::playquery_handler;
		handlers[ PlayReply ] = &Dispatch::playreply_handler;
		handlers[ Give3Query ] = &Dispatch::give3query_handler;
		handlers[ Terminate ] = &Dispatch::terminate_handler;
		//	handlers[Reset] = &Dispatch::reset_handler;
		handlers[ Give3Reply ] = &Dispatch::give3reply_handler;
		handlers[ PlayReply ] = &Dispatch::playreply_handler;

	}
	map_type::iterator resp = handlers.find( type );
	if ( resp == handlers.end() ) {
		LOG_PLACE() << "No handler for " << type << ".\n";
		return &Dispatch::error_handler;
	}
	return resp->second;
}
开发者ID:luispedro,项目名称:hearts,代码行数:30,代码来源:dispatch.cpp

示例11: probe

void probe (map_type& testMap, std::string name, auto keys, auto values, size_t toFind)
{
    // map_type
    const int width (15);
    const int precision (6);
    std::cout << std::setw (width) << keys.size () << " : " << std::setw (width) << name << " : " << std::flush;
    high_resolution_clock::time_point startTime = high_resolution_clock::now ();
    auto itValues = begin (values);
    for_each (begin (keys), end (keys), [&testMap, &itValues](size_t key)
              {
                  testMap.insert (std::make_pair (key, (*itValues++)));
              });

    high_resolution_clock::time_point findTime = high_resolution_clock::now ();
    size_t currFind = 0;
    for (auto k : keys)
    {
        if (currFind >= toFind)
            break;

        bool exists = testMap.find (k) != testMap.end ();
        if (exists)
            ++currFind;
    }
    high_resolution_clock::time_point endTime   = high_resolution_clock::now ();
    duration<double> time_span_insert = duration_cast<duration<double>> (findTime-startTime);
    duration<double> time_span_find = duration_cast<duration<double>> (endTime-findTime);
    std::cout << "time insert = " << std::fixed << std::setprecision (precision) << time_span_insert.count () << "  time find = " << std::setprecision (precision) << time_span_find.count () << std::setw (width) << "   found = " << std::setw (width) << currFind << std::endl;
}
开发者ID:pspe,项目名称:various,代码行数:29,代码来源:test_map_with_vector.cpp

示例12: print

 void print() const{
     enterExclusive();
     map_type::const_iterator iter = _item_map.begin();
     for(; iter != _item_map.end(); ++iter){
         iter->second->print();
     }
     leaveExclusive();
 }
开发者ID:MIPS,项目名称:karma,代码行数:8,代码来源:statistics.hpp

示例13: max_index

 /** Compute the max of the element values
  * This operation returns the first element if the vector is empty.
  */
 mwIndex max_index() {
     mwIndex index=0;
     double maxval=std::numeric_limits<double>::min();
     for (map_type::iterator it=map.begin(),itend=map.end();it!=itend;++it) {
         if (it->second>maxval) { maxval = it->second; index = it->first; }
     }
     return index;
 }
开发者ID:kkloste,项目名称:hkgrow,代码行数:11,代码来源:hktest_mex.cpp

示例14: flush

 void flush(){
     enterExclusive();
     map_type::iterator iter = _item_map.begin();
     for(; iter != _item_map.end(); ++iter){
         iter->second->flush();
     }
     leaveExclusive();
 }
开发者ID:MIPS,项目名称:karma,代码行数:8,代码来源:statistics.hpp

示例15: get

 /** Get an element and provide a default value when it doesn't exist
  * This command does not insert the element into the vector
  */
 double get(mwIndex index, double default_value=0.0) {
     map_type::iterator it = map.find(index);
     if (it == map.end()) {
         return default_value;
     } else {
         return it->second;
     }
 }
开发者ID:kkloste,项目名称:hkgrow,代码行数:11,代码来源:hktest_mex.cpp


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