• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ map_t类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: map_unset

int map_unset(map_t map, void *key, void **olddata)
{
	bucket_t *b, *prev;
	int hash;

	if (!map || !key)
		return RETERROR(EINVAL, -1);

	hash = map->hashf(map->size, key);
	b = map->buckets[hash];
	prev = 0;
	while (b)
	{
		if (!map->compf(key, b->key))
		{
			if (prev)
				prev->next = b->next;
			else
				map->buckets[hash] = b->next;
			mem_init(olddata, b->data);
			map_bucket_free(map, b);
			return -- map->count;;
		}
		prev = b;
		b = b->next;
	}
	return RETERROR(ERANGE, -1);
}
开发者ID:BackupTheBerlios,项目名称:scelib-svn,代码行数:28,代码来源:map.c


示例2: go

            void go( bool construct )
            {
                typedef std::pair<std::string,int> key_t;
                typedef std::map<key_t, int> map_t;

                static map_t map;
                key_t id = key_t( file, line );
                map_t::iterator it = map.find( id );

                if( construct )
                {
                    compiled = ( it != map.end() );
                    if( !compiled )
                    {
                        static int list = 0;
                        list++;
                        map.insert( std::pair<key_t,int>( id, list) );
                        glNewList( list, GL_COMPILE );
                    }
                }
                else
                {
                    int list = it->second;
                    if( !compiled )
                    {
                        glEndList();
                        //std::cout << "compiled list #" << list << std::endl;
                    }
                    //std::cout << "calling list #" << list << std::endl;
                    glCallList( list );
                }
            }
开发者ID:r-lyeh,项目名称:eve,代码行数:32,代码来源:lists.hpp


示例3: init

	void init()
	{
		map_t::iterator it = gMap.find(mKey);
		if (it == gMap.end()) {
			throw std::runtime_error("uninitialized mongo_stream sink");
		}
		mObject = it->second;
	}
开发者ID:ignatz,项目名称:boost_mongo,代码行数:8,代码来源:mongo_stream.hpp


示例4:

		~constants()
		{
#ifndef NDEBUG
			for( map_t::const_iterator it = map.begin(); it != map.end(); ++it )
				if( !used[ it->first ].as<bool>() )
					fprintf( stdout, ( moon9::iostring() << "<moon9/play/constants.hpp> says: warning, unused constant '" << it->first << "'" << std::endl ).c_str() );
#endif
		}
开发者ID:shammellee,项目名称:moon9,代码行数:8,代码来源:constants.hpp


示例5: debug

		std::string debug( const moon9::iostring &head = moon9::iostring(), const moon9::iostring &format12 = "\t\1=\2\n", const moon9::iostring &footer = moon9::iostring() ) //const
		{
			moon9::iostring body;

			for( map_t::const_iterator it = map.begin(); it != map.end(); ++it )
				body << moon9::iostring( format12, it->first, it->second );

			return head + body + footer;
		}
开发者ID:shammellee,项目名称:moon9,代码行数:9,代码来源:constants.hpp


示例6: Exception

void		ModuleNcurses::display(map_t const & map)
{
  uint		x;

  if (werase(this->win) == ERR)
    throw Exception(strerror(errno));
  for (uint y = 0; y != map.size() ; ++y)
    {
      for (x = 0; x != map.size() ; ++x)
	display_slot(x, y, map[y][x]);
    }
  if (wrefresh(this->win) == ERR)
    throw Exception(strerror(errno));
}
开发者ID:jboulouloubi,项目名称:Nibbler,代码行数:14,代码来源:ModuleNcurses.cpp


示例7: check_and_add_output_file

static void check_and_add_output_file(Module* NewMod, const std::string& str)
{
    typedef std::map<std::string, Module*> map_t;
    static map_t files;

    map_t::iterator i = files.find(str);
    if (i != files.end()) {
        Module* ThisMod = i->second;
        error(Loc(), "Output file '%s' for module '%s' collides with previous module '%s'. See the -oq option",
            str.c_str(), NewMod->toPrettyChars(), ThisMod->toPrettyChars());
        fatal();
    }
    files.insert(std::make_pair(str, NewMod));
}
开发者ID:doniexun,项目名称:ldc,代码行数:14,代码来源:module.cpp


示例8: to

		static std::uint32_t to(state_t &state, const map_t &map_val)
		{
			::lua_createtable(state, (int)map_val.size(), (int)map_val.size());

			std::for_each(map_val.cbegin(), map_val.cend(), 
				[&state](const typename map_t::value_type &val)
			{
				convertion_t<typename map_t::key_type>::to(state, val.first);
				convertion_t<typename map_t::mapped_type>::to(state, val.second);

				::lua_settable(state, -3);
			});

			return map_val.size() == 0 ? 0 : 1;
		}
开发者ID:Strongc,项目名称:lua_reg,代码行数:15,代码来源:converter.hpp


示例9: lock

const char* name_t::map_string(const char* str, std::size_t hash) {
    typedef std::unordered_map<std::size_t, const char*> map_t;
    typedef std::lock_guard<std::mutex> lock_t;

    static std::mutex sync_s;

    lock_t lock(sync_s);

    static adobe::unique_string_pool_t pool_s;
    static map_t map_s;
    map_t::const_iterator found(map_s.find(hash));

    return found == map_s.end() ? map_s.emplace(hash, pool_s.add(str)).first->second
                                : found->second;
}
开发者ID:BobArcher,项目名称:adobe_source_libraries,代码行数:15,代码来源:name.cpp


示例10: map_set

int map_set(map_t map, void *key, void *data, void **olddata)
{
	bucket_t *b;

	if (!map || !key)
		return RETERROR(EINVAL, -1);

	b = map_bucket_find(map, key);
	if (b)
	{
		mem_init(olddata, b->data);
		b->data = data;
	}
	else
	{
		int hash;

		if (!map_resize(map, map->count + 1, 0))
			return -1;

		if (!(b = map_bucket_alloc(map, key, data)))
			return -1;

		hash = map->hashf(map->size, key);
		b->next = map->buckets[hash];
		map->buckets[hash] = b;
		++ map->count;
	}

	return map->count;
}
开发者ID:BackupTheBerlios,项目名称:scelib-svn,代码行数:31,代码来源:map.c


示例11: glClear

void		ModuleOpenGL::display(map_t const & map)
{
    uint		x;
    uint		y = 0;

    glClear(GL_COLOR_BUFFER_BIT);
    glViewport(0, 0, this->width, this->height);
    xglBegin(GL_QUADS);
    glColor3ub(51, 51, 51);
    glVertex2d(-1,-1);
    glVertex2d(-1,1);
    glColor3ub(30, 30, 30);
    glVertex2d(1,1);
    glVertex2d(1,-1);
    xglEnd();
    for (std::vector<std::vector<slot_t> >::const_iterator it_y = map.begin(); it_y != map.end(); ++it_y)
    {
        x = 0;
        for (std::vector<slot_t>::const_iterator it_x = (*it_y).begin(); it_x != (*it_y).end(); ++it_x)
        {
            display_slot(x, y, (*it_x));
            ++x;
        }
        ++y;
    }
    xglFlush();
    SDL_GL_SwapBuffers();
}
开发者ID:jboulouloubi,项目名称:Nibbler,代码行数:28,代码来源:ModuleOpenGL.cpp


示例12: change

    // change
    std::pair<class map_t::const_iterator, bool>
    change(const KEY_T& key, const PAY_T& pay) {
      if (file_mode == READ_ONLY) {
        throw std::runtime_error("Error: change called in RO mode");
      }

      // erase the old element
      size_t num_erased = erase(key);
      if (num_erased != 1) {
        // erase failed
        return std::pair<class map_t::const_iterator, bool>(map->end(), false);
      } else {
        // put in new
        return map->emplace(key, pay);
      }
    }
开发者ID:Beman,项目名称:btree_test,代码行数:17,代码来源:map_btree.hpp


示例13: insert

 template <typename... IndexType> void insert(IndexType const&... ind) {
  map_index_n.insert({{ind...}, size()});
  // reorder the indices which are always given in the order of the indices tuple
  map_t m;
  int i = 0;
  for (auto const& p : map_index_n) m.insert({p.first, i++});
  std::swap(m, map_index_n);
 }
开发者ID:dhirschm,项目名称:triqs,代码行数:8,代码来源:fundamental_operator_set.hpp


示例14: runtime_error

    // insert
    std::pair<class map_t::const_iterator, bool>
    emplace(const KEY_T& key, const PAY_T& pay) {
      if (file_mode == READ_ONLY) {
        throw std::runtime_error("Error: emplace called in RO mode");
      }

      return map->emplace(key, pay);
    }
开发者ID:Beman,项目名称:btree_test,代码行数:9,代码来源:map_btree.hpp


示例15: set_fields

		void set_fields(doid_t do_id, const map_t &fields)
		{
			m_log->trace() << "Setting fields on obj-" << do_id << endl;

			YAML::Node document;
			if(!load(do_id, document))
			{
				return;
			}

			// Get the fields from the file that are not being updated
			const Class* dcc = g_dcf->get_class_by_name(document["class"].as<string>());
			ObjectData dbo(dcc->get_id());
			YAML::Node existing = document["fields"];
			for(auto it = existing.begin(); it != existing.end(); ++it)
			{
				const Field* field = dcc->get_field_by_name(it->first.as<string>());
				if(!field)
				{
					m_log->warning() << "Field '" << it->first.as<string>()
					                 << "', loaded from '" << filename(do_id)
					                 << "', does not exist." << endl;
					continue;
				}

				auto found = fields.find(field);
				if(found == fields.end())
				{
					vector<uint8_t> value = read_yaml_field(field, it->second, do_id);
					if(value.size() > 0)
					{
						dbo.fields[field] = value;
					}
				}
			}

			// Add in the fields that are being updated:
			for(auto it = fields.begin(); it != fields.end(); ++it)
			{
				dbo.fields[it->first] = it->second;
			}

			write_yaml_object(do_id, dcc, dbo);
		}
开发者ID:Echocage,项目名称:Astron,代码行数:44,代码来源:YAMLDatabase.cpp


示例16: write

 void write()
 {
     static comma::csv::output_stream< interval_t< From, To > > ostream( std::cout, ocsv );
     static comma::csv::ascii< from_t< std::string > > from_ascii( ascii_csv );
     static comma::csv::ascii< to_t< std::string > > to_ascii( ascii_csv );
     for( typename map_t::iterator it = map.begin(); it != map.end(); ++it )
     {
         bound_t< bound_type > from = it->first.lower();
         bound_t< bound_type > to = it->first.upper();
         interval_t< From, To > interval;
         bool from_has_value = true;
         bool to_has_value = true;
         if( from.value ) { interval.from.value = *from.value; }
         else if( use_limits ) { interval.from.value = limits< From >::lowest(); }
         else if( empty ) { interval.from.value = static_cast< From >( *empty ); }
         else { from_has_value = false; }
         if( to.value ) { interval.to.value = *to.value; }
         else if( use_limits ) { interval.to.value = limits< To >::max(); }
         else if( empty ) { interval.to.value = static_cast< To >( *empty ); }
         else { to_has_value = false; }
         const set_t& s = it->second;
         if( csv.binary() )
         {
             if( intervals_only ) { ostream.write( interval ); ostream.flush(); continue; }
             for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v ) { ostream.write( interval, *v ); }
             ostream.flush();
         }
         else
         {
             for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v )
             {
                 std::string payload( intervals_only ? "" : *v );
                 ostream.ascii().ascii().put( interval, payload );
                 if( !from_has_value ) { from_ascii.put( from_t< std::string >(), payload ); }
                 if( !to_has_value ) { to_ascii.put( to_t< std::string >(), payload); }
                 std::cout << payload << std::endl;
                 if( intervals_only ) { break; }
             }
         }
     }
 }
开发者ID:sheenzhaox,项目名称:comma,代码行数:41,代码来源:csv-interval.cpp


示例17: Exception

void		ModuleSDL::display(map_t const & map)
{
  uint		x, y;
  int		r;

  y = 0;
  r = SDL_FillRect(this->s_ecran, NULL, SDL_MapRGB(this->s_ecran->format, 0, 0, 0));
  if (r == -1)
    throw Exception(SDL_GetError());
  for (std::vector<std::vector<slot_t> >::const_iterator it_y = map.begin(); it_y != map.end(); ++it_y)
    {
      x = 0;
      for (std::vector<slot_t>::const_iterator it_x = (*it_y).begin(); it_x != (*it_y).end(); ++it_x)
	{
	  display_slot(x, y, (*it_x));
	  ++x;
	}
      ++y;
    }
  r = SDL_Flip(this->s_ecran);
  if (r == -1)
    throw Exception(SDL_GetError());
}
开发者ID:jboulouloubi,项目名称:Nibbler,代码行数:23,代码来源:ModuleSDL.cpp


示例18: insertEmptyNodePtr

inline void insertEmptyNodePtr(map_t& map, hash_t key) {
	map.put(key, unique_ptr<Node>(new Node{}));
}
开发者ID:dblalock,项目名称:dig,代码行数:3,代码来源:tree.cpp


示例19: touch

 /** Mark an element as recently used. */
 void touch (const key_type& k)
 {
     auto found (map_.find(k));
     assert(found != map_.end());
     if (found != map_.end())
         list_.splice(list_.begin(), list_, found->second);
 }
开发者ID:friederschueler,项目名称:hexahedra,代码行数:8,代码来源:lru_cache.hpp


示例20: found

    boost::optional<mapped_type&> try_get (const key_type& k) const
    {
        auto found (map_.find(k));
        if (found == map_.end())
            return boost::optional<mapped_type&>();

        return found->second->second;
    }
开发者ID:friederschueler,项目名称:hexahedra,代码行数:8,代码来源:lru_cache.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ map_type类代码示例发布时间:2022-05-31
下一篇:
C++ map_session_list_t类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap