本文整理汇总了C++中hashmap::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ hashmap::contains方法的具体用法?C++ hashmap::contains怎么用?C++ hashmap::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hashmap
的用法示例。
在下文中一共展示了hashmap::contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2:
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; }
}
}
示例3: r
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;
}
}
示例4: Error
// Mapping from module ID to the actual module name.
Try<string> getModuleName(ModuleID id)
{
if (!moduleNames.contains(id)) {
return Error("Module '" + stringify(id) + "' not found");
}
return moduleNames[id];
}
示例5: concretize
bool
is_up_to_date (url dir) {
string name_dir= concretize (dir);
if (cache_valid->contains (name_dir)) return cache_valid [name_dir];
int l= last_modified (dir, false);
if (is_cached ("validate_cache.scm", name_dir)) {
int r= as_int (cache_get ("validate_cache.scm", name_dir) -> label);
if (l == r) {
cache_valid (name_dir)= true;
return true;
}
//cout << name_dir << " no longer up to date " << r << " -> " << l << "\n";
}
//else cout << name_dir << " not up to date " << l << "\n";
cache_set ("validate_cache.scm", name_dir, as_string (l));
cache_valid (name_dir)= false;
// FIXME: we should explicitly remove all data concerning files in 'dir'
// from the various caches. Indeed, at a next run of TeXmacs, the directory
// will be regarded as up to date, but the other caches may still contain
// outdated data. Careful: invalidating the cache lines should not
// give rise to a performance penaly (e.g. go through all entries of
// 'cache_data', or reloading unchanged files many times).
// See also 'declare_out_of_date'.
return false;
}
示例6: string
string
uni_upcase_char (string s) {
if (N(s) == 1) {
unsigned char c= s[0];
if ((c >= 'a' && c <= 'z') ||
(c >= ((unsigned char) 0xA0) && (c <= ((unsigned char) 0xBF))) ||
(c >= ((unsigned char) 0xE0)))
return string ((char) (c - 0x20));
return s;
}
else if (starts (s, "<#") && ends (s, ">")) {
int code= from_hexadecimal (s (2, N(s) - 1));
if (code >= 0x3AC && code <= 0x3CE) {
if (code >= 0x3B1 && code <= 0x3CB) code -= 0x20;
else if (code >= 0x3AC && code <= 0x3AC) code -= 0x26;
else if (code >= 0x3AD && code <= 0x3AF) code -= 0x25;
else if (code >= 0x3CC && code <= 0x3CC) code -= 0x40;
else if (code >= 0x3CD && code <= 0x3CE) code -= 0x3f;
}
else if (code >= 0x450 && code <= 0x45F) code -= 0x50;
else if (code >= 0x430 && code <= 0x44F) code -= 0x20;
else if (code >= 0x460 && code <= 0x4FF) {
if ((code & 1) == 1) code -= 1;
}
return "<#" * as_hexadecimal (code) * ">";
}
else {
init_case_tables ();
if (upcase_tab->contains (s)) return upcase_tab[s];
return s;
}
}
示例7: s
static bool
is_special (string s) {
if (N (special_table) == 0) {
special_table ("*")= "";
special_table ("<noplus>")= "";
special_table ("<nocomma>")= "";
special_table ("<nospace>")= "";
special_table ("<nobracket>")= "";
special_table ("<nosymbol>")= "";
special_table ("-")= "<minus>";
special_table ("|")= "<mid>";
special_table ("'")= "<#2B9>";
special_table ("`")= "<backprime>";
}
if (starts (s, "<big-."))
special_table (s)= "";
if (starts (s, "<big-") && (ends (s, "-1>") || ends (s, "-2>"))) {
string ss= s (0, N(s)-3) * ">";
//cout << "Search " << ss << "\n";
if (unicode_provides (ss))
special_table (s)= ss;
ss= "<big" * s (5, N(s)-3) * ">";
//cout << "Search " << ss << "\n";
if (unicode_provides (ss))
special_table (s)= ss;
ss= "<" * s (5, N(s)-3) * ">";
if (ends (ss, "lim>")) ss= ss (0, N(ss)-4) * ">";
//cout << "Search " << ss << "\n";
if (unicode_provides (ss))
special_table (s)= ss;
}
return special_table->contains (s);
}
示例8: h
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);
}
示例9: while
static void
parse_constant (hashmap<string,string>& t, string s, int& pos) {
int i=pos;
if (pos>=N(s)) return;
while ((i<N(s)) && belongs_to_identifier (s[i])) i++;
string r= s (pos, i);
if (t->contains (r) && t(r)=="#2060c0") { pos=i; return; }
}
示例10: ASSERT
array<int>
get_hyphens (string s,
hashmap<string,string> patterns,
hashmap<string,string> hyphenations, bool utf8) {
ASSERT (N(s) != 0, "hyphenation of empty string");
if (utf8) s= cork_to_utf8 (s);
if (hyphenations->contains (s)) {
string h= hyphenations [s];
array<int> penalty (str_length (s, utf8)-1);
int i=0, j=0;
while (h[j] == '-') j++;
i++; goto_next_char (h, j, utf8);
while (i < N(penalty)+1) {
penalty[i-1]= HYPH_INVALID;
while (j < N(h) && h[j] == '-') {
penalty[i-1]= HYPH_STD;
j++;
}
i++;
goto_next_char (h, j, utf8);
}
//cout << s << " --> " << penalty << "\n";
return penalty;
}
else {
s= "." * lower_case (s) * ".";
// cout << s << "\n";
int i, j, k, l, m, len;
array<int> T (str_length (s, utf8)+1);
for (i=0; i<N(T); i++) T[i]=0;
for (len=1; len < MAX_SEARCH; len++)
for (i=0, l=0; i<N(s) - len; goto_next_char (s, i, utf8), l++) {
string r= patterns [s (i, i+len)];
if (!(r == "?")) {
// cout << " " << s (i, i+len) << " => " << r << "\n";
for (j=0, k=0; j<=len; j++, k++) {
if ((k<N(r)) && (r[k]>='0') && (r[k]<='9')) {
m=((int) r[k])-((int) '0');
k++;
}
else m=0;
if (m>T[l+j]) T[l+j]=m;
}
}
}
array<int> penalty (N(T)-4);
for (i=2; i < N(T)-4; i++)
penalty [i-2]= (((T[i]&1)==1)? HYPH_STD: HYPH_INVALID);
if (N(penalty)>0) penalty[0] = penalty[N(penalty)-1] = HYPH_INVALID;
if (N(penalty)>1) penalty[1] = penalty[N(penalty)-2] = HYPH_INVALID;
if (N(penalty)>2) penalty[N(penalty)-3] = HYPH_INVALID;
// cout << s << " --> " << penalty << "\n";
return penalty;
}
}
示例11:
string
persistent_get (url dir, string key) {
string v= local_prefix (dir) * key;
if (!persistent_has->contains (v)) {
persistent_init_key (dir, key);
persistent_retrieve (dir, key, persistent_file [v], persistent_hash [v]);
}
return persistent_cache [v];
}
示例12: abbrevs
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);
}
示例13:
void
ad_hoc_language_rep::hyphenate (
string s, int after, string& left, string& right)
{
if (hyphens->contains (s)) {
array<int> penalty= get_hyphens (s);
std_hyphenate (s, after, left, right, penalty[after]);
}
else base->hyphenate (s, after, left, right);
}
示例14: while
int
common_len (tree id, tree p, int c, int delta,
hashmap<tree,tree> corr,
hashmap<tree,tree> next) {
int len= 0;
while (true) {
c += delta;
if (c < 0 || c >= N(p)) break;
if (!corr->contains (p[c])) break;
tree next_ids= corr[p[c]];
if (!next->contains (id)) break;
tree next_id= next[id];
bool found= false;
for (int k=0; k<N(next_ids); k++)
found= found || (next_ids[k] == next_id);
if (!found) break;
len++;
}
return len;
}
示例15: N
static string
replace (string s, hashmap<int,string> w, hashmap<int,string> b) {
string r;
for (int i=0; i<N(s); )
if (w->contains (i)) {
r << b[i];
i += N(w[i]);
}
else r << s[i++];
return r;
}