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


C++ map_t类代码示例

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


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


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