本文整理汇总了C++中map_t::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ map_t::insert方法的具体用法?C++ map_t::insert怎么用?C++ map_t::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map_t
的用法示例。
在下文中一共展示了map_t::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
}
示例2: 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);
}
示例3: 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));
}
示例4: Exception
//Returns a reference to the resource associated with the file name 'key' if it exists in memory.
//Otherwise it loads the texture into memory, and returns a reference to the the resource.
T &Load(key_type const &key) noexcept(false)
{
map_i i = m_map.find(key);
if(i != m_map.end())
{
return *i->second.get(); //return resource if exists
}
//else, load resource
ptr_t p {onLoadResource(key)};
if(p.get() == NULL)
{
throw Exception(std::string("Error loading Image at ") + key);
}
m_map.insert(std::make_pair(key, std::move(p)));
return *m_map[key].get();
}
示例5: insert
std::pair< map_t::iterator, bool > insert( const rule_type type )
{
return map.insert( map_t::value_type( internal::demangle< Name >(), rule_info( type ) ) );
}