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


C++ hashmap类代码示例

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


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

示例1: invert

void
edit_env_rep::local_update (hashmap<string,tree>& old_patch,
			    hashmap<string,tree>& change)
{
  old_patch->pre_patch (back, env);
  old_patch->post_patch (change, env);
  change= invert (back, env);
}
开发者ID:Easycker,项目名称:itexmacs,代码行数:8,代码来源:env.cpp

示例2: ad_hoc_language

language
ad_hoc_language (language base, tree hyphs) {
  static hashmap<tree,int> abbrevs;
  if (!abbrevs->contains (hyphs))
    abbrevs (hyphs)= N (abbrevs);
  string name= base->res_name * "-" * as_string (abbrevs [hyphs]);
  if (language::instances -> contains (name)) return language (name);
  return tm_new<ad_hoc_language_rep> (name, base, hyphs);
}
开发者ID:KarlHegbloom,项目名称:texmacs,代码行数:9,代码来源:language.cpp

示例3: window_delete

void
window_delete (int win) {
    static hashmap<int,bool> busy (false);
    if (busy->contains (win)) return;
    busy (win)= true;
    ASSERT (window_table->contains (win), "window does not exist");
    widget pww= window_table [win];
    window_table->reset (win);
    send_destroy (pww);
    destroy_window_widget (pww);
    busy (win)= false;
}
开发者ID:mgubi,项目名称:texmacs,代码行数:12,代码来源:tm_window.cpp

示例4: parse_other_op_index

static void
parse_other_op_index (hashmap<string,string>& t, string s, int& pos) {
  int i;
  i=13 ;
  if( i > N(s) ) i=N(s) ;
  for (i=13; i >= 1; i--) {
    string r=s(pos,pos+i);
    if (t->contains(r) && (t(r)=="op index")) {
      pos=pos+i; return; }
    if (t->contains(r) && (t(r)=="operator")) {
      return; }
    if (t->contains(r) && (t(r)=="op assign")) {
      return; }
  }
}
开发者ID:KarlHegbloom,项目名称:texmacs,代码行数:15,代码来源:r_language.cpp

示例5: 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"));
}
开发者ID:ycaihua,项目名称:mesos,代码行数:31,代码来源:metrics.cpp

示例6: 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;
}
开发者ID:OvertimeDog,项目名称:mesos,代码行数:35,代码来源:metrics.cpp

示例7: texmacs_invarianted

tree
texmacs_invarianted (tree t, tree p, int c, string src,
                     hashmap<tree,tree> corr,
                     hashmap<tree,tree> pred,
                     hashmap<tree,tree> succ) {
  if (corr->contains (t)) {
    tree oids= corr[t], ids (TUPLE);
    for (int i=0; i<N(oids); i++) {
      int b, e;
      if (get_range (oids[i], b, e, src)) ids << oids[i];
    }
    if (N(ids) >= 1) {
      tree id= texmacs_best_match (ids, p, c, corr, pred, succ);
      if (id != tree (UNINIT)) return compound ("ilx", id);
    }
  }
  if (is_atomic (t)) return t;
  else {
    int i, n= N(t);
    tree r (t, n);
    for (i=0; i<n; i++)
      r[i]= texmacs_invarianted (t[i], t, i, src, corr, pred, succ);
    return r;
  }
}
开发者ID:KarlHegbloom,项目名称:texmacs,代码行数:25,代码来源:conservative_totex.cpp

示例8: stringify

std::string stringify(const hashmap<K, V>& map)
{
  std::ostringstream out;
  out << "{ ";
  typename hashmap<K, V>::const_iterator iterator = map.begin();
  while (iterator != map.end()) {
    out << stringify(iterator->first);
    out << ": ";
    out << stringify(iterator->second);
    if (++iterator != map.end()) {
      out << ", ";
    }
  }
  out << " }";
  return out.str();
}
开发者ID:AsylumCorp,项目名称:mesos,代码行数:16,代码来源:stringify.hpp

示例9: getPval

// Returns P_i(perm)
inline unsigned short getPval(perm_t perm, int i, const hashmap &Phashmap) {
  // if (Phashmap.getpayload(perm) == NULL) { // !!
  //   cout<<"perm read failed: "<<endl;
  //   displayperm(perm);
  // }
  // assert(Phashmap.getpayload(perm) != NULL); // !!
  return ((unsigned short*)Phashmap.getpayload(perm))[i];
}
开发者ID:williamkuszmaul,项目名称:patternavoidance,代码行数:9,代码来源:countpatterns.cpp

示例10: get_subtree_paths

static void
get_subtree_paths (tree t, path p, hashmap<tree,path>& h) {
  if (h->contains (t)) h (t)= path (-1);
  else h (t)= p;
  if (is_compound (t))
    for (int i=0; i<N(t); i++)
      get_subtree_paths (t[i], p * i, h);
}
开发者ID:KarlHegbloom,项目名称:texmacs,代码行数:8,代码来源:conservative_totex.cpp

示例11: while

text_property
oriental_language_rep::advance (tree t, int& pos) {
  string s= t->label;
  if (pos == N(s)) return &tp_normal_rep;

  if (s[pos] == ' ') {
    pos++;
    return &tp_space_rep;
  }

  if (pos < N(s) && !test (s, pos, "<#")) {
    while (pos < N(s) && s[pos] != ' ' && !test (s, pos, "<#"))
      tm_char_forwards (s, pos);
    return &tp_cjk_no_break_rep;
  }

  int start= pos;
  tm_char_forwards (s, pos);
  string c= s (start, pos);
  int next= pos;
  tm_char_forwards (s, next);
  string x= s (pos, next);

  if (punct->contains (c)) {
    if (punct->contains (x) || pos == N(s))
      return &tp_cjk_no_break_period_rep;
    else return &tp_cjk_period_rep;
  }
  else {
    if (punct->contains (x) || pos == N(s))
      return &tp_cjk_no_break_rep;
    else return &tp_cjk_normal_rep;
  }
}
开发者ID:svn2github,项目名称:texmacs,代码行数:34,代码来源:text_language.cpp

示例12: remove

void
unregister_pointer (string id, observer which) {
  // cout << "Unregister: " << id << " -> " << which << "\n";
  // cout << "Unregister: " << id << " -> " << obtain_tree (which) << "\n";
  list<observer>& l1= id_resolve (id);
  l1= remove (l1, which);
  if (is_nil (l1)) id_resolve->reset (id);
  list<string>& l2= pointer_resolve (which);
  l2= remove (l2, id);
  if (is_nil (l2)) pointer_resolve->reset (which);
}
开发者ID:svn2github,项目名称:texmacs,代码行数:11,代码来源:link.cpp

示例13: remain

 std::vector<int> search(std::string s){
     if (s.length() == 0) {
         return indexes;
     }else{
         char first = s.at(0);
         if (children.find(first) != children.end()) {
             std::string remain(s.substr(1));
             return children[first]->search(remain);
         }
     }
     
     std::vector<int> tmp;
     return tmp;
 }
开发者ID:lbl1985,项目名称:TestCPPCode,代码行数:14,代码来源:Q18_08.cpp

示例14: insertString

 void insertString(std::string s, int index){
     indexes.push_back(index);
     if (s.size()>0) {
         value = s.at(0);
         std::shared_ptr<SuffixTreeNode> child;
         if (children.find(value) != children.end()) {
             child = children[value];
         }else{
             child.reset(new SuffixTreeNode());
             children[value] = child;
         }
         std::string remain(s.substr(1));
         child->insertString(remain, index);
     }
 }
开发者ID:lbl1985,项目名称:TestCPPCode,代码行数:15,代码来源:Q18_08.cpp

示例15: 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;
      }
    }
  }
开发者ID:mpark,项目名称:mesos,代码行数:27,代码来源:master_slave_reconciliation_tests.cpp


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