本文整理汇总了C++中hashmap::get方法的典型用法代码示例。如果您正苦于以下问题:C++ hashmap::get方法的具体用法?C++ hashmap::get怎么用?C++ hashmap::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hashmap
的用法示例。
在下文中一共展示了hashmap::get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: foreachpair
Future<hashmap<string, double>> MetricsProcess::__snapshot(
const Option<Duration>& timeout,
const hashmap<string, Future<double>>& metrics,
const hashmap<string, Option<Statistics<double>>>& statistics)
{
hashmap<string, double> snapshot;
foreachpair (const string& key, const Future<double>& value, metrics) {
// TODO(dhamon): Maybe add the failure message for this metric to the
// response if value.isFailed().
if (value.isPending()) {
CHECK_SOME(timeout);
VLOG(1) << "Exceeded timeout of " << timeout.get()
<< " when attempting to get metric '" << key << "'";
} else if (value.isReady()) {
snapshot[key] = value.get();
}
Option<Statistics<double>> statistics_ = statistics.get(key).get();
if (statistics_.isSome()) {
snapshot[key + "/count"] = static_cast<double>(statistics_.get().count);
snapshot[key + "/min"] = statistics_.get().min;
snapshot[key + "/max"] = statistics_.get().max;
snapshot[key + "/p50"] = statistics_.get().p50;
snapshot[key + "/p90"] = statistics_.get().p90;
snapshot[key + "/p95"] = statistics_.get().p95;
snapshot[key + "/p99"] = statistics_.get().p99;
snapshot[key + "/p999"] = statistics_.get().p999;
snapshot[key + "/p9999"] = statistics_.get().p9999;
}
}
return snapshot;
}
示例2: OK
Future<http::Response> MetricsProcess::__snapshot(
const http::Request& request,
const hashmap<string, Future<double> >& metrics,
const hashmap<string, Option<Statistics<double> > >& statistics)
{
JSON::Object object;
foreachpair (const string& key, const Future<double>& value, metrics) {
// Value.
if (value.isReady()) {
object.values[key] = value.get();
}
// Statistics.
Option<Statistics<double> > statistics_ = statistics.get(key).get();
if (statistics_.isSome()) {
object.values[key + "/count"] = statistics_.get().count;
object.values[key + "/min"] = statistics_.get().min;
object.values[key + "/max"] = statistics_.get().max;
object.values[key + "/p50"] = statistics_.get().p50;
object.values[key + "/p90"] = statistics_.get().p90;
object.values[key + "/p95"] = statistics_.get().p95;
object.values[key + "/p99"] = statistics_.get().p99;
object.values[key + "/p999"] = statistics_.get().p999;
object.values[key + "/p9999"] = statistics_.get().p9999;
}
}
return http::OK(object, request.query.get("jsonp"));
}
示例3: foreach
foreach (const Future<TaskStatus>& taskStatus, taskStatuses) {
AWAIT_READY(taskStatus);
Option<TaskState> taskState = taskStates.get(taskStatus->task_id());
ASSERT_SOME(taskState);
switch (taskState.get()) {
case TASK_STAGING: {
ASSERT_EQ(TASK_STARTING, taskStatus->state())
<< taskStatus->DebugString();
taskStates[taskStatus->task_id()] = TASK_STARTING;
break;
}
case TASK_STARTING: {
ASSERT_EQ(TASK_RUNNING, taskStatus->state())
<< taskStatus->DebugString();
taskStates[taskStatus->task_id()] = TASK_RUNNING;
break;
}
default: {
FAIL() << "Unexpected task update: " << taskStatus->DebugString();
break;
}
}
}
示例4: searchStock
static void searchStock(char *symbol)
{
unsigned int usedIndex, hashIndex, symbolHash, chainLgth;
stock s;
if (hm.get(symbol, s, symbolHash, hashIndex, usedIndex, chainLgth)) {
cout << "found " << left << setw(8) << symbol;
printAdditional(symbolHash, hashIndex, usedIndex, chainLgth);
}
else
cout << symbol << " not found" << endl;
}
示例5: Error
Try<string> nsname(int nsType)
{
const hashmap<int, string> nsnames = {
{CLONE_NEWNS, "mnt"},
{CLONE_NEWUTS, "uts"},
{CLONE_NEWIPC, "ipc"},
{CLONE_NEWNET, "net"},
{CLONE_NEWUSER, "user"},
{CLONE_NEWPID, "pid"},
{CLONE_NEWCGROUP, "cgroup"}
};
Option<string> nsname = nsnames.get(nsType);
if (nsname.isNone()) {
return Error("Unknown namespace");
}
return nsname.get();
}
示例6:
std::vector<K> hashmap<K, V>::hashDifference (const hashmap& src) const
{
std::vector<K> diff;
size_t listsize;
size_t hashIndex;
signed searchIndex;
for (size_t i = 0; i < numBuckets; i++)
{
listsize = dictionary[i].size();
for (size_t j = 0; j < listsize; j++)
{
pairptr<K, V> sample = dictionary[i].nPeek(j);
if (false == src.get(sample->getKey()))
{
diff.push_back(sample.getKey());
}
}
}
return diff;
}
示例7: OK
Future<http::Response> MetricsProcess::__snapshot(
const http::Request& request,
const Option<Duration>& timeout,
const hashmap<string, Future<double> >& metrics,
const hashmap<string, Option<Statistics<double> > >& statistics)
{
JSON::Object object;
foreachpair (const string& key, const Future<double>& value, metrics) {
// TODO(dhamon): Maybe add the failure message for this metric to the
// response if value.isFailed().
if (value.isPending()) {
CHECK_SOME(timeout);
VLOG(1) << "Exceeded timeout of " << timeout.get() << " when attempting "
<< "to get metric '" << key << "'";
} else if (value.isReady()) {
object.values[key] = value.get();
}
Option<Statistics<double> > statistics_ = statistics.get(key).get();
if (statistics_.isSome()) {
object.values[key + "/count"] = statistics_.get().count;
object.values[key + "/min"] = statistics_.get().min;
object.values[key + "/max"] = statistics_.get().max;
object.values[key + "/p50"] = statistics_.get().p50;
object.values[key + "/p90"] = statistics_.get().p90;
object.values[key + "/p95"] = statistics_.get().p95;
object.values[key + "/p99"] = statistics_.get().p99;
object.values[key + "/p999"] = statistics_.get().p999;
object.values[key + "/p9999"] = statistics_.get().p9999;
}
}
return http::OK(object, request.query.get("jsonp"));
}