Exemplo n.º 1
0
void mergeSorted(const VecInt& a, const VecInt& b, VecInt& out)
{
	VecInt::const_iterator i = a.begin(); 
	VecInt::const_iterator j = b.begin(); 
	
	while(i!= a.end() && j != b.end())
	{
		while(i!= a.end() && j!=b.end() && *i <= *j)
		{
			out.push_back(*i);
			i++;
		}
		
		while(i!= a.end() && j!= b.end() && *j <= *i)
		{
			out.push_back(*j);
			j++;
		}
	}
	for( ; i!=a.end(); ++i)
		out.push_back(*i);

	for( ; j!=b.end(); ++j)
		out.push_back(*j);
}
Exemplo n.º 2
0
int GoalVisitController::encodeFact(const proposition* p)
{
  const parameter_symbol_list& vsl = *p->getArgs();
  VecInt indexes;
  for (parameter_symbol_list::const_iterator itr = vsl.begin(); itr != vsl.end(); itr++) {
    const string& arg = (*itr)->getName();
    ostringstream os;
    StringToInt::const_iterator index = params.find(arg);
    if (index == params.end()) {
      index = objectTbl.find(arg);
      //labels.push_back((*itr)->getName());
    //} else {
      assert (index != objectTbl.end()); // reference to a constant in action def that hasn't been defined
    }
    os << index->second;
    indexes.push_back(index->second);
    labels.push_back(os.str());
  }
  int factNum = getIndex(this->offsets, mults, p->getHead()->getName(), indexes);
  cout << "(" << factNum << ")";
  return factNum;
}