本文整理汇总了C++中VS::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ VS::begin方法的具体用法?C++ VS::begin怎么用?C++ VS::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VS
的用法示例。
在下文中一共展示了VS::begin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: play
void play(MSI& rank, VS& toks) {
SS oprs;
SD nums;
string out = "";
char str[100];
cout << "# from infix to postfix!!!" << endl;
for (VS::iterator i = toks.begin(); i != toks.end(); i++) {
string tok = *i;
cout << "There is a " << tok << ": ";
if (is_num(tok)) {
cout << "push to output" << endl;
sprintf(str, "%.6lf ", stod(tok));
out += str;
nums.push(stod(tok));
}
else if (tok == ",") {
cout << "flush the stack until '('" << endl;
while (oprs.top() != "(")
calc(oprs, nums, out);
}
else if (tok == ")") {
cout << "flush the stack until '(' and check if there's a func" << endl;
while (oprs.top() != "(")
calc(oprs, nums, out);
oprs.pop();
if (!oprs.empty() && is_func(oprs.top()))
calc(oprs, nums, out);
}
else {
cout << "push to stack" << endl;
if ( is_unary(tok) && (i == toks.begin() || rank[*(i - 1)] > 0) )
oprs.push("u" + tok);
else {
while (!is_func(tok) && tok != "(" && !oprs.empty() && rank[oprs.top()] <= rank[tok]) {
cout << "\t*** stack.top() has higher precedence" << endl;
calc(oprs, nums, out);
}
oprs.push(tok);
}
}
cout << "\tcurrent output: " << out << endl
<< "\tcurrent stack: " << oprs << endl;
}
while (!oprs.empty())
calc(oprs, nums, out);
cout << "There is nothing left, so flush the stack to output" << endl
<< "\tcurrent output: " << out << endl
<< "#transformation completed!!!" << endl
<< "Postfix Exp: " << out << endl
<< "RESULT: " << nums.top() << endl << endl;
}
示例2: UDFind
string UDFind(VS code){
int i, j, n = code.size(); string t; Code c;
set<string> s; /* Mark tails already seen */
priority_queue<Code> tails; /* Keep track of current tails */
sort(code.begin(), code.end(), cmpSS);
s.clear();
for(i = 0; i < n; i++) for(j = i+1; j < n; j++){
if(code[i] == code[j]) return code[i];
CHECK(code[i], code[j]);
CHECK(code[j], code[i]);
}
s.clear();
while(!tails.empty()){
Code top = tails.top(); tails.pop();
if(s.count(top.b)) continue;
s.insert(top.b);
for(j = 0; j < n; j++){
if(top.b == code[j]) return top.a+top.b;
CHECK2(top.b, code[j]);
CHECK2(code[j], top.b);
}
}
return "";
}
示例3: calc
VS calc( VS s ) {
Set S;
for ( VS::iterator it_i = s.begin(); it_i != s.end(); ++ it_i ) {
string a = *it_i;
string b = rotate(a);
cout << a << ", " << b << endl;
if ( ! is_valid(a) ) {
if ( is_valid(b) ) {
S.insert(b);
}
} else if ( ! is_valid(b) ) {
if ( is_valid(a) ) {
S.insert(a);
}
} else {
if ( S.count(a) )
S.insert(b);
else if ( S.count(b) )
S.insert(a);
else
S.insert(min(a, b));
}
}
if ( S.size() != s.size() )
return VS();
VS res(S.begin(), S.end());
return res;
}
示例4: main
int main()
{
VVI vv;
VI v(3);
v[0] = 1;
v[1] = 5;
v[2] = 6;
vv.PB(v);
v[0] = 2;
v[1] = 7;
v[2] = 8;
vv.PB(v);
REPSZ(i, vv) print(vv[i]);
// sort(vv.begin(), vv.end(), cmpVector);
REPSZ(i, vv) print(vv[i]);
cout << "//////"<<endl;
VI v2;
v2.PB(2);
v2.PB(1);
v2.PB(3);
sort(v2.begin(), v2.end(), mycmp);
// sort(v2.begin(), v2.end());
print(v2);
VS vs;
vs.PB("12");
vs.PB("9");
vs.PB("312");
sort(vs.begin(), vs.end(), sss);
print(vs);
}
示例5: convert
string convert( VS list ) {
OSS oss;
for ( VS::iterator it_i = list.begin(); it_i != list.end(); ++ it_i ) {
oss << *it_i;
if ( it_i + 1 != list.end() )
oss << " ";
}
return oss.str();
}
示例6: find
LEARN::~LEARN ()
{
INOUT io;
VS vf = io.getfilename ("encodelib/", "*");
if (find (vf.begin (), vf.end (), "encodelib/xorand") == vf.end ()
|| find (vf.begin (), vf.end (), "encodelib/pemis") == vf.end ()
|| find (vf.begin (), vf.end (), "encodelib/zobrist0") == vf.end ()
|| find (vf.begin (), vf.end (), "encodelib/zobrist1") == vf.end ()
|| find (vf.begin (), vf.end (), "encodelib/zobrist2") == vf.end ()
|| find (vf.begin (), vf.end (), "encodelib/zobrist3") == vf.end ()
|| find (vf.begin (), vf.end (), "encodelib/zobrist4") == vf.end ()
|| find (vf.begin (), vf.end (), "encodelib/zobrist5") == vf.end ()
|| find (vf.begin (), vf.end (), "encodelib/zobrist6") == vf.end ()
|| find (vf.begin (), vf.end (), "encodelib/zobrist7") == vf.end ()
|| find (vf.begin (), vf.end (), "encodelib/zobrist8") == vf.end ())
{
g_init.save_xorand ("encodelib/xorand");
io.save (lib_pemis, "encodelib/pemis");
io.save (lib_zobrist[0], "encodelib/zobrist0");
io.save (lib_zobrist[1], "encodelib/zobrist1");
io.save (lib_zobrist[2], "encodelib/zobrist2");
io.save (lib_zobrist[3], "encodelib/zobrist3");
io.save (lib_zobrist[4], "encodelib/zobrist4");
io.save (lib_zobrist[5], "encodelib/zobrist5");
io.save (lib_zobrist[6], "encodelib/zobrist6");
io.save (lib_zobrist[7], "encodelib/zobrist7");
io.save (lib_zobrist[8], "encodelib/zobrist8");
clog << "All FSM been saved ." << endl;
sleep (2000);
}
}
示例7: main
int main(int argc, char *argv[])
{
libpipe::ctc::Pipeline pipeline;
pipeline = generatePipeline();
pipeline.run();
typedef std::vector<std::string> VS;
VS trace;
trace = pipeline.getTrace();
for (VS::const_iterator i = trace.begin(); i != trace.end(); ++i) {
std::cout << *i << '\n';
}
return EXIT_SUCCESS;
}
示例8: _getKey
// TODO: make this func more generic ?
string LogEntry::_getKey(const string &line) {
stringstream s;
s << funcName << "(";
for (VS::iterator i = params.begin(), ie = params.end(); i != ie; i++) {
string p = *i;
// should not compare any pointer / array type
if (p.find("0x") == string::npos && p.find("{") == string::npos)
s << p;
else
s << "--"; // this is a field that is not used in the comparison
if (i + 1 != ie)
s << ",";
}
s << ")";
return s.str();
}