本文整理汇总了C++中stringstream::ignore方法的典型用法代码示例。如果您正苦于以下问题:C++ stringstream::ignore方法的具体用法?C++ stringstream::ignore怎么用?C++ stringstream::ignore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stringstream
的用法示例。
在下文中一共展示了stringstream::ignore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getRule
unsigned int getRule(stringstream& ss, S2Setmap& pt2base, V2Imap& goodman) {
char c;
ss >> c;
assert(c == '(');
string sym = "";
ss >> sym;
unsigned int symI = sym2base[sym];
// printf("got symbol %s (%u)\n",sym.c_str(),symI);
vector<unsigned int> kSyms;
kSyms.push_back(symI);
while(true) {
c = ss.peek();
if(c == ' ') { //it's a space
ss.ignore(1); //ignore that space
} else if(c == '(') { //nonterminal
//get child node index
unsigned int index = getRule(ss,pt2base,goodman);
kSyms.push_back(index);
} else if (c == ')') {
ss.ignore(1); //burn closing paren
// printf("Finished Rule with sym %s and %lu kids\n",sym.c_str(),kSyms.size()-1);
unsigned int index = 0;
while(kSyms.size() > 3) { //try to add glue rule
// printf("K = %lu\n",kSyms.size());
unsigned int r = kSyms.back();
kSyms.pop_back();
unsigned int l = kSyms.back();
kSyms.pop_back();
unsigned int glueI = nSym*2;
vector<unsigned int> gluerule;
gluerule.push_back(glueI);//glue symbol
gluerule.push_back(l);
gluerule.push_back(r);
unsigned int glueindex = 0;
V2Imap::iterator fter = goodman.find(gluerule);
if(fter == goodman.end()) { //new node
goodman[gluerule] = goodmanIndex;
baseSym.push_back(glueI);
glueindex = goodmanIndex;
canL.push_back(false);
canR.push_back(false);
canL[l] = true;
canR[r] = true;
leftlook[l].push_back(make_pair(r,goodmanIndex));
bmap[make_pair(l,r)].insert(goodmanIndex);
goodmanIndex++;
} else { //seen it
glueindex = fter->second;
}
kSyms.push_back(glueindex);
}
V2Imap::iterator fter = goodman.find(kSyms);
if(fter == goodman.end()) { //new node
goodman[kSyms] = goodmanIndex;
baseSym.push_back(symI);
index = goodmanIndex;
canL.push_back(false);
canR.push_back(false);
goodmanIndex++;
if(kSyms.size() == 3) {
//add index -> l r
// printf("BR : %u -> %u %u\n",index,kSyms[1],kSyms[2]);
canL[kSyms[1]] = true;
canR[kSyms[2]] = true;
leftlook[kSyms[1]].push_back(make_pair(kSyms[2],index));
bmap[make_pair(kSyms[1],kSyms[2])].insert(index);
} else { //one child
//add index -> k
umap[kSyms[1]].insert(index);
//printf("UR : %u -> %u\n",index,kSyms[1]);
}
} else { //seen it
index = fter->second;
}
return index;
} else { //terminal
string term = "";
while(ss.peek() != ')') {
term += ss.get();
}
// printf("got terminal %s\n",term.c_str());
ss.ignore(1); //burn closing paren
//.........这里部分代码省略.........