本文整理汇总了C++中MapT::find方法的典型用法代码示例。如果您正苦于以下问题:C++ MapT::find方法的具体用法?C++ MapT::find怎么用?C++ MapT::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapT
的用法示例。
在下文中一共展示了MapT::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
double
Note2FreqTable::operator[](string str) const
{
MapT::const_iterator iter = m_rep.find(str);
assert(iter != m_rep.end());
return iter->second;
}
示例2: load_and_init_with_map
static void load_and_init_with_map(const char* file, double* cpu_times, MapT& M)
{
FILE* f = fopen(file,"r");
if(f == NULL){
fprintf(stderr, "Could not open %s file: %s", file, strerror(errno));
exit(-1);
}
double nanosec;
char ops[48];
char line[512];
std::string tmp = "";
while(fgets(line,sizeof(line),f)){
unsigned op;
if (sscanf(line, "%47[^:]:\t%lf nanoseconds", ops, &nanosec) == 2) {
tmp = ops;
auto ite = M.find(ops);
if (ite != M.end()) {
op = ite->second;
cpu_times[op] = nanosec;
} else
continue;
}
}
fclose(f);
}
示例3:
bool
Cstore::VarRef::getValue(string& value, vtw_type_e& def_type)
{
vector<string> result;
MapT<string, bool> added;
def_type = ERROR_TYPE;
for (size_t i = 0; i < _paths.size(); i++) {
if (_paths[i].first.size() == 0) {
// empty path
continue;
}
if (added.find(_paths[i].first.back()) != added.end()) {
// already added
continue;
}
if (_paths[i].second == ERROR_TYPE
&& !_cstore->cfgPathExists(_paths[i].first, _active)) {
// path doesn't exist => empty string
added[""] = true;
result.push_back("");
continue;
}
if (_paths[i].second != ERROR_TYPE) {
// set def_type. all types should be the same if multiple entries exist.
def_type = _paths[i].second;
}
added[_paths[i].first.back()] = true;
result.push_back(_paths[i].first.back());
}
if (result.size() == 0) {
// got nothing
return false;
}
if (result.size() > 1 || def_type == ERROR_TYPE) {
/* if no type is available or we are returning "joined" multiple values,
* treat it as text type.
*/
def_type = TEXT_TYPE;
}
value = "";
for (size_t i = 0; i < result.size(); i++) {
if (i > 0) {
value += " ";
}
value += result[i];
}
return true;
}
示例4: get_value_or
ValueT get_value_or(const MapT &map, const KeyT &key, ValueT def) {
typename MapT::const_iterator it(map.find(key));
return it != map.end() ? it->second : def;
}