本文整理汇总了C++中hashmap::end方法的典型用法代码示例。如果您正苦于以下问题:C++ hashmap::end方法的具体用法?C++ hashmap::end怎么用?C++ hashmap::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hashmap
的用法示例。
在下文中一共展示了hashmap::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: 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);
}
}
示例4: flushPSTBlk
// SPIMI-1: write current postings to intermediate files
//
// {word} => {ndoc => [doc][frq]}
// pst.trm.x pst.doc.x
//
// where x is the id of current intermediate file
//
void IndexWriter::flushPSTBlk(hashmap<string, vector<pair<int, int> > >&pst, int turn) {
ofstream ftrm, fdoc;
string prefix = path+"/"+POSTINGS_FILE;
ftrm.open((prefix+".trm."+itoa(turn)).c_str(), ios::binary);
fdoc.open((prefix+".doc."+itoa(turn)).c_str(), ios::binary);
hashmap<string, vector<pair<int, int> > >::iterator it;
vector<pair<int, int> >::iterator jt;
vector<string> list;
for (it = pst.begin(); it != pst.end(); ++it) {
list.push_back(it->first);
}
sort(list.begin(), list.end());
for (unsigned i = 0; i < list.size(); ++i) {
it = pst.find(list[i]);
string &term = list[i];
int ndoc = it->second.size(), cnt = 0, accum = 0;
for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
int did = jt->first;
int frq = jt->second;
didbuf[cnt] = did;
frqbuf[cnt] = frq;
accum += frq;
assert(accum > 0 || !(cout << accum << endl));
cnt++;
}
fwrite(fdoc, &ndoc, sizeof(ndoc));
fwrite(fdoc, didbuf, sizeof(didbuf[0])*ndoc);
fwrite(fdoc, frqbuf, sizeof(frqbuf[0])*ndoc);
TermAttr attr;
attr.str = term;
attr.df = ndoc;
attr.cf = accum;
attr.flush(ftrm);
}
ftrm.close();
fdoc.close();
}