コード例 #1
0
/**
 * \brief Constructor.
 */
tunnel::player_pending_action::player_pending_action( const std::string & str )
{
  std::vector<std::string> params;
  
  claw::text::split(params, str, '|');
  if ( params.size() == 5 ) 
    {
      size_t t;
      std::istringstream iss0(params[0]);
      iss0 >> t;
      if ( t == start_action ) 
	pending_type = start_action;
      else if ( t == stop_action ) 
	pending_type = stop_action;
      else
	pending_type = do_action;
      
      std::istringstream iss1(params[1]);
      iss1 >> date; 
      
      std::istringstream iss2(params[2]);
      iss2 >> player_index; 
      
      std::istringstream iss3(params[3]);
      iss3 >> action; 
      
      std::istringstream iss4(params[4]);
      iss4 >> duration;
    }
コード例 #2
0
ファイル: Source.cpp プロジェクト: madamcz/ewolucja
void start(int &m, int &l, int &w, int &i, bool &c)
{
	string in;
	cout << "Algorytm ewolucyjny. Podaj wartosci parametrow." << endl;

	cout << "mi: " << endl;
	cin >> in;
	istringstream iss(in);
	iss >> m;

	cout << "lambda: " << endl;
	cin >> in;
	istringstream iss1(in);
	iss1 >> l;

	cout << "wymiar: " << endl;
	cin >> in;
	istringstream iss2(in);
	iss2 >> w;

	cout << "liczba iteracji: " << endl;
	cin >> in;
	istringstream iss3(in);
	iss3 >> i;

	cout << "czy drukowac wyniki czesciowe? (t/n): " << endl;
	cin >> in;
	if(in == "t")
		c = true;
	else 
		c = false;
}
コード例 #3
0
ファイル: Cube.cpp プロジェクト: RadekJ1992/OgreGame
Cube::Cube(Ogre::SceneManager& mSceneMgr, Ogre::Real x, Ogre::Real y, Ogre::Real z) {
    Ogre::SceneManager::MovableObjectIterator it= mSceneMgr.getMovableObjectIterator("Entity");
    Ogre::Real lowestY = 10;
    _mSceneMgr = &mSceneMgr;

    while (it.hasMoreElements())
    {
        std::string _name = it.getNext()->getName();

        if (_name != "GroundEntity" && _name != "RoboOgre") {
            try {
                std::vector<std::string> _temp = Cube::split(_name, ':');
                // 0:'Cube' 1:'x' 2:'y' 3:'z'
                if (_temp[0] == "Cube") {
                    int _tempX;
                    std::istringstream iss1(_temp[1]);
                    iss1 >> _tempX;
                    int _tempY;
                    std::istringstream iss2(_temp[2]);
                    iss2 >> _tempY;
                    int _tempZ;
                    std::istringstream iss3(_temp[3]);
                    iss3 >> _tempZ;
                    if (_tempX > (x - 25) && _tempX < (x + 25) && _tempZ > (z - 25) && _tempZ < (z + 25))
                    {
                        if (lowestY <= _tempY) lowestY = _tempY+25;
                    }
                }
            }
            catch (...) {    }
        }
    }
    _name = "Cube:"+Ogre::StringConverter::toString(x,6,0, '_',0) +":"+ Ogre::StringConverter::toString(lowestY,6,0, '_',0)+":"+Ogre::StringConverter::toString(z,6,0, '_',0);

    _cubeEntity = mSceneMgr.createEntity(_name, "cube.mesh");

    _cubeNode = mSceneMgr.getRootSceneNode()->createChildSceneNode();

    _cubeNode->attachObject(_cubeEntity);

    _cubeNode->showBoundingBox(true);

    _cubeEntity->setCastShadows(true);

    _cubeNode->setPosition(x, lowestY, z);

    _cubeNode->scale(CUBE_SCALE, CUBE_SCALE, CUBE_SCALE);

}
コード例 #4
0
ファイル: TestFullModel.cpp プロジェクト: Gorov/LowRankFCM
int TestFullModel::LoadInstanceInit(ifstream &ifs) {
    int id;
    int fea_id;
    int beg1 = 0, end1 = 0, beg2 = 0, end2 = 0;
    char line_buf[5000], line_buf2[1000];
    vector<int> trigram_id;
    trigram_id.resize(3);
    ifs.getline(line_buf, 1000, '\n');
    if (!strcmp(line_buf, "")) {
        return 0;
    }
    ((LrFcemInstance*) inst) -> Clear();
    {
        istringstream iss(line_buf);
        iss >> inst -> label;
        feat2int::iterator iter = labeldict.find(inst -> label);
        if (iter == labeldict.end()) {
            id = (int)labeldict.size();
            //            cout << inst->label << endl;
            labeldict[inst -> label] = id;
        }
        
        iter = lab_model -> vocabdict.find(inst -> label);
        if (iter == lab_model -> vocabdict.end()) {
            id = (int)lab_model -> vocabdict.size();
            lab_model -> vocabdict[inst -> label] = id;
        }
        
        iss >> beg1; iss >> end1;
        inst -> ne1_len = end1 + 1 - beg1;
        for (int i = 0; i < inst -> ne1_len; i++) {
            iss >> inst -> ne1_words[i];
            ToLower(inst -> ne1_words[i]);
        }
        iss >> beg2; iss >> end2;
        inst -> ne2_len = end2 + 1 - beg2;
        for (int i = 0; i < inst -> ne2_len; i++) {
            iss >> inst -> ne2_words[i];
            ToLower(inst -> ne2_words[i]);
        }
    }
    {
        ifs.getline(line_buf, 5000, '\n');
        {
            ifs.getline(line_buf2, 1000, '\n');
            istringstream iss3(line_buf2);
            int tmpint;
            string ne_tag;
            iss3 >> tmpint;
            for (int i = 0; i < inst -> ne1_len; i++) {
                iss3 >> inst -> ne1_types[i];
                inst -> ne1_types[i] = ProcSenseTag(inst -> ne1_types[i]);
                if(fea_params.ner) {
                    iss3 >> ne_tag;
                    inst -> ne1_nes[i] = ProcNeTag(ne_tag);
                }
            }
        }
        {
            ifs.getline(line_buf2, 1000, '\n');
            istringstream iss4(line_buf2);
            int tmpint;
            string ne_tag;
            iss4 >> tmpint;
            for (int i = 0; i < inst -> ne2_len; i++) {
                iss4 >> inst -> ne2_types[i];
                inst -> ne2_types[i] = ProcSenseTag(inst -> ne2_types[i]);
                if (fea_params.ner) {
                    iss4 >> ne_tag;
                    inst -> ne2_nes[i] = ProcNeTag(ne_tag);
                }
            }
        }
コード例 #5
0
ファイル: test_buf_istream.cpp プロジェクト: rdumitriu/geryon
void test1Gaps() {
    geryon::server::GUniformMemoryPool pool(BUF_SZ, 1, 0);
    std::vector<geryon::server::GBufferHandler> buffers;
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(0).get().buffer()[0] = 'a'; //0
    buffers.at(0).get().buffer()[1] = 'X'; //1
    buffers.at(0).get().buffer()[2] = 'a'; //2
    buffers.at(0).get().setMarker(3);
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(1).get().buffer()[0] = 'b'; //3
    buffers.at(1).get().buffer()[1] = 'b'; //4
    buffers.at(1).get().buffer()[2] = 'X'; //5
    buffers.at(1).get().buffer()[3] = 'X'; //6
    buffers.at(1).get().buffer()[4] = 'b'; //7
    buffers.at(1).get().setMarker(5);
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(2).get().buffer()[0] = 'c'; //8
    buffers.at(2).get().buffer()[1] = 'c'; //9
    buffers.at(2).get().buffer()[2] = 'c'; //10
    buffers.at(2).get().buffer()[3] = 'X'; //11
    buffers.at(2).get().setMarker(4);
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(3).get().buffer()[0] = 'X'; //12
    buffers.at(3).get().buffer()[1] = 'd'; //13
    buffers.at(3).get().buffer()[2] = 'd'; //14
    buffers.at(3).get().buffer()[3] = 'X'; //15
    buffers.at(3).get().setMarker(4);
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(4).get().buffer()[0] = 'X'; //16
    buffers.at(4).get().buffer()[1] = 'e'; //17
    buffers.at(4).get().buffer()[2] = 'e'; //18
    buffers.at(4).get().buffer()[3] = 'X'; //19
    buffers.at(4).get().setMarker(4);
    
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(5).get().buffer()[0] = 'X'; //19
    buffers.at(5).get().setMarker(1);
    
    //1st test : abb
    geryon::server::GIstreambuff buff1(buffers);
    buff1.addGap(1, 2);
    buff1.setup(1, 5);
    std::istream iss1(&buff1);
    std::string s;
    iss1 >> s; //our stream
    if("abb" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test1Gaps (1)";
    }
    std::cout << "String 1 is >>" << s << "<<" << std::endl;
    
    //2nd test: all abbbcccddee
    geryon::server::GIstreambuff buff2(buffers);
    buff2.addGap(1, 2);
    buff2.addGap(5, 7);
    buff2.addGap(11, 13);
    buff2.addGap(15, 17);
    buff2.addGap(19, 20);
    buff2.setup(1, 20);
    std::istream iss2(&buff2);
    iss2 >> s; //our stream
    if("abbbcccddee" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test1Gaps (2)";
    }
    std::cout << "String 2 is >>" << s << "<<" << std::endl;
    
    //3rd test: reset the stream
    buff2.setup(2,4);
    std::istream iss2_1(&buff2); //our stream
    iss2_1 >> s;
    if("ab" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test1Gaps (3.1)";
    }
    std::cout << "String 3.1 is >>" << s << "<<" << std::endl;
    buff2.addGap(11, 13);
    buff2.addGap(15, 17);
    buff2.setup(11,18);
    iss2.rdbuf(&buff2);
    iss2 >> s;
    if("dde" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test1Gaps (3.2)";
    }
    std::cout << "String 3.2 is >>" << s << "<<" << std::endl;
    
    
    //4th test: empty (EOF)
    geryon::server::GIstreambuff buff3(buffers);
    buff3.addGap(11, 13);
    buff2.setup(11,13);
    std::istream iss3(&buff3);
    if(iss3 >> s) { //yeap, this should return false
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test1Gaps (4)";
    }
    std::cout << "String 4 is >>" << s << "<<" << std::endl; //unchanged
}
コード例 #6
0
ファイル: test_buf_istream.cpp プロジェクト: rdumitriu/geryon
void test1() {
    geryon::server::GUniformMemoryPool pool(BUF_SZ, 1, 0);
    std::vector<geryon::server::GBufferHandler> buffers;

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(0).get().buffer()[0] = 'a'; //0
    buffers.at(0).get().buffer()[1] = 'a'; //1
    buffers.at(0).get().setMarker(2);

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(1).get().buffer()[0] = 'b'; //2
    buffers.at(1).get().buffer()[1] = 'b'; //3
    buffers.at(1).get().buffer()[2] = 'b'; //4
    buffers.at(1).get().setMarker(3);

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(2).get().buffer()[0] = 'c'; //5
    buffers.at(2).get().buffer()[1] = 'c'; //6
    buffers.at(2).get().buffer()[2] = 'c'; //7
    buffers.at(2).get().buffer()[3] = 'c'; //8
    buffers.at(2).get().setMarker(4);

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(3).get().buffer()[0] = 'd'; //9
    buffers.at(3).get().setMarker(1);

    //1st test : abbbc
    geryon::server::GIstreambuff buff1(buffers, 1, 6);
    std::istream iss1(&buff1);
    std::string s;
    iss1 >> s; //our stream
    if("abbbc" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed (1)";
    }
    std::cout << "String 1 is >>" << s << "<<" << std::endl;

    //2nd test: all aabbbccccd
    geryon::server::GIstreambuff buff2(buffers, 0, 10);
    std::istream iss2(&buff2);
    iss2 >> s; //our stream
    if("aabbbccccd" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed (2)";
    }
    std::cout << "String 2 is >>" << s << "<<" << std::endl;

    //3rd test: reset the stream
    buff2.setup(1,9);
    std::istream iss2_1(&buff2); //our stream
    iss2_1 >> s;
    if("abbbcccc" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed (3.1)";
    }
    std::cout << "String 3.1 is >>" << s << "<<" << std::endl;
    buff2.setup(2,8);
    iss2.rdbuf(&buff2);
    iss2 >> s;
    if("bbbccc" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed (3.2)";
    }
    std::cout << "String 3.2 is >>" << s << "<<" << std::endl;


    //4th test: empty (EOF)
    geryon::server::GIstreambuff buff3(buffers, 0, 0);
    std::istream iss3(&buff3);
    if(iss3 >> s) { //yeap, this should return false
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed (4)";
    }
    std::cout << "String 4 is >>" << s << "<<" << std::endl; //unchanged
}
コード例 #7
0
ファイル: functions.cpp プロジェクト: nohle/algorithms-1
//NOTE: The file index starts at 1, but we'll subtract one
//      to match vector index.
void readInFromFile( vector<Node> &g, string fileName )
{
    //clear g
    g = {};
    
    Node emptyNode;
    
    ifstream inFile( fileName, ios::in );
    if ( !inFile )
    {
        cerr << endl << "File could not be opened." << endl << endl;
        exit(1);
    }
    
    string line;
    
    while( getline(inFile, line) )
    {
        istringstream iss1(line);
        string tab;
        
        string sindex;
        long index;
        getline(iss1, sindex, '\t');
        istringstream issIndex(sindex);
        issIndex >> index;
        //Make index match array index
        --index;
        //cout << "Index: " << index << endl;
        
        //Add a node
        g.push_back(emptyNode);

        
        
        while( getline(iss1, tab, '\t') )
        {
            //extra crap (like space or newline) in last iteration
            if( tab.length() >= 3 )
            {
                istringstream iss2(tab);
                
                string comma;
                
                int counter = 0;
                long iVert = -1000;
                long edgeDist = -1000;
                while( getline(iss2, comma, ',') )
                {
                    istringstream iss3(comma);
                    
                    if( counter == 0 )
                    {
                        iss3 >> iVert;
                        //Make vertex match array index
                        --iVert;
                        counter++;
                    }
                    else if( counter == 1 )
                    {
                        iss3 >> edgeDist;
                        counter++;
                    }
                    else
コード例 #8
0
ファイル: vm.lp.cpp プロジェクト: DRC9702/BigDataXREU2015
void define_data(IloEnv env) {
  string line("           ");
  ifstream myfile ("/home/DavidRC/data.txt");
  int i=0;
  int j=0;
  int x=0;
  int y=0;

  if (myfile.is_open())
  {
    i=0;
	  j=0;
    
	  getline(myfile,line);
	  n=atoi(line.c_str());
	  IloNumArray l(env,n);
	  NumMatrix w(env,n);
    
    for(i=0; i<n; i++)
    {
      w[i]=IloNumArray(env,n);
    }
	  
	  getline (myfile,line);
    
	  istringstream iss1(line);  
	  	while (iss1 && j<n) 
		{ 
			string subs; 
			iss1 >> subs; 
			string temp=subs;
			if(temp.compare("")==0)
			{
				continue;
			}
			else
			{

            l[j]=atoi(subs.c_str());
			}
			j++;
	    }
     exit(1);

     i=0;
	 j=0;
	 while ( getline (myfile,line) && i<n)
     {
	    istringstream iss2(line);
          j=0;

		while (iss2 && j<n) 
		{ 
			string subs; 
			iss2 >> subs; 
			string temp=subs;

			if(temp.compare("")==0)
			{
				continue;
                        j++;
			}
			else
			{

            w[i][j]=atoi(subs.c_str());
            			j++;
			}
	    }
		i++;
    }

	  m=atoi( line.c_str() );

    IloNumArray c(env,m);
	  NumMatrix d(env,m);
    
    for(i=0; i<m; i++)
    {
      d[i]=IloNumArray(env,m);
    } 
		  
  i=0;
  j=0;    
	getline (myfile,line);
	istringstream iss3(line);
	while (iss3 && j<m) 
	{ 
		string subs; 
		iss3 >> subs; 
		string temp=subs;
		if(temp.compare("")==0)
		{
			continue;
		}
		else
		{
           c[j]=atoi(subs.c_str());
		}
		j++;
	}
		
	i=0;
	j=0;
	while ( getline (myfile,line) && i<m)
    {
	    istringstream iss4(line);
          j=0;
		while (iss4 && j<m) 
		{ 
			string subs; 
			iss4 >> subs; 
			string temp=subs;
			if(temp.compare("")==0)
			{
				continue;
			}
			else
			{
            d[i][j]=atoi(subs.c_str());
			}
			j++;
	    }
		i++;
    }
    myfile.close();
  }