예제 #1
0
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();
}
예제 #2
0
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
0
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
0
파일: test.cpp 프로젝트: ak795/acm
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
0
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;
}
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;
}
예제 #7
0
// 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();
}
예제 #8
0
파일: learn.cpp 프로젝트: shoutgo/shoutgo
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);
    }
}