本文整理汇总了C++中map_t::find方法的典型用法代码示例。如果您正苦于以下问题:C++ map_t::find方法的具体用法?C++ map_t::find怎么用?C++ map_t::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map_t
的用法示例。
在下文中一共展示了map_t::find方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: 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;
}
示例4: 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;
}
示例5: remove
/** Remove an element from the cache. */
void remove (const key_type& k)
{
auto found (map_.find(k));
if (found == map_.end())
return;
list_.erase(found->second);
map_.erase(found);
--size_;
}
示例6: 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));
}
示例7: map_string
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;
}
示例8: 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();
}
示例9: 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);
}
示例10:
///parameters class-like element access
_object const & operator[](std::string const & key) const {
auto it = object_map.find(key);
if ( it== object_map.end()) TRIQS_RUNTIME_ERROR<<"Key : "<< key<< " not found";
return it->second;
}
示例11: has_key
bool has_key(std::string const & key) const { return object_map.find(key) != object_map.end();}
示例12: Free
//Deletes the entry of a key in the resource map.
//This will call deleter_type to deallocate the resource from memory as well.
void Free(key_type const &key) noexcept
{
map_i i = m_map.find(key);
m_map.erase(i);
}
示例13: find
// find
typename map_t::const_iterator find(const KEY_T& key) const {
class map_t::const_iterator itr = map->find(key);
return itr;
}