Пример #1
0
bool Solution::isFound(vector<vector<char> > &board, const char *w, int x, int y)
{
	if(x<0||y<0||x>=m||y>=n||board[x][y]=='\0'||*w!=board[x][y])
		return false;
	if(*(w+1)=='\0')
		return true;
	char t=board[x][y];
	board[x][y]='\0';
	if(isFound(board,w+1,x-1,y)||isFound(board,w+1,x+1,y)||isFound(board,w+1,x,y-1)||isFound(board,w+1,x,y+1))
		return true;
	board[x][y]=t;
	return false;
}
Пример #2
0
	bool isFound(vector<vector<char> > &board, string word, int x, int y, int i) {
		if (i == word.length())return true;
		if (x < 0 || y < 0 || x == board.size() || y == board[0].size()
			 || word[i] != board[x][y])
			return false;
		char t = board[x][y];
		board[x][y] = '\0';
		if (isFound(board, word, x - 1, y, i + 1) || isFound(board, word, x + 1, y, i + 1)
			|| isFound(board, word, x, y - 1, i + 1) || isFound(board, word, x, y + 1, i + 1))
			return true;
		board[x][y] = t;
		return false;
	}
    /*! 
     * @brief tests for load_module()
     *
     *
     *
     */
    void test_load_module()
    {
        ::RTM::ManagerServant *pman = new ::RTM::ManagerServant();
        ::RTC::ReturnCode_t ret;
        try
        {
            ret = pman->load_module(".libs/DummyModule1.so","DummyModule1Init");
            CPPUNIT_ASSERT_EQUAL(::RTC::RTC_OK, ret);
            CPPUNIT_ASSERT(isFound(pman->get_loaded_modules(), 
                                   ".//.libs/DummyModule1.so"));
        }
        catch(...)
        {
	    CPPUNIT_FAIL("Exception thrown.");
        }

        //illegal file name.
        try
        {
            ret = pman->load_module("bar.so","DummyModule1Init");
	    CPPUNIT_FAIL("Exception not thrown.");
        }
        catch(...)
        {
            CPPUNIT_ASSERT(!isFound(pman->get_loaded_modules(), ".//bar.so"));
        }
        //illegal function name.
        try
        {
            ret = pman->load_module("DummyModule1i.so","foo");
	    CPPUNIT_FAIL("Exception not thrown.");
        }
        catch(...)
        {
            CPPUNIT_ASSERT(isFound(pman->get_loaded_modules(), 
                                   ".//.libs/DummyModule1.so"));
        }
        //loading overlaps
        ret = pman->load_module(".libs/DummyModule1.so","DummyModule1Init");
        CPPUNIT_ASSERT_EQUAL(::RTC::RTC_OK, ret);
        CPPUNIT_ASSERT(isFound(pman->get_loaded_modules(),
                               ".//.libs/DummyModule1.so"));

        //lodding another module
        ret = pman->load_module(".libs/DummyModule2.so","DummyModule2Init");
        CPPUNIT_ASSERT_EQUAL(::RTC::RTC_OK, ret);
        CPPUNIT_ASSERT(isFound(pman->get_loaded_modules(),
                               ".//.libs/DummyModule2.so"));

        delete pman;
    }
Пример #4
0
bool isFound(char** board, int row, int col, char*word, int rIndex, int cIndex)
{
    if(*word == '\0') return true; 
    if(rIndex>=row || cIndex>=col || rIndex<0 || cIndex<0 || *word!=board[rIndex][cIndex]) return false;
    char t = board[rIndex][cIndex];
    board[rIndex][cIndex] = '\0'; 
    if(isFound(board, row, col, word+1, rIndex+1, cIndex) || 
       isFound(board, row, col, word+1, rIndex-1, cIndex) || 
       isFound(board, row, col, word+1, rIndex, cIndex+1) || 
       isFound(board, row, col, word+1, rIndex, cIndex-1)) 
             return true;
    board[rIndex][cIndex] = t; 
    return false; 
}
    /*! 
     * @brief tests for unload_modules()
     *
     *
     *
     */
    void test_unload_modules()
    {
        ::RTM::ManagerServant *pman = new ::RTM::ManagerServant();
        ::RTC::ReturnCode_t ret;
        try
        {
            ret = pman->load_module(".libs/DummyModule1.so","DummyModule1Init");
            CPPUNIT_ASSERT(isFound(pman->get_loaded_modules(),
                                   ".//.libs/DummyModule1.so"));
            CPPUNIT_ASSERT_EQUAL(::RTC::RTC_OK, ret);
        }
        catch(...)
        {
	    CPPUNIT_FAIL("Exception thrown.");
        }
        try
        {
            ret = pman->load_module(".libs/DummyModule2.so","DummyModule2Init");
            CPPUNIT_ASSERT_EQUAL(::RTC::RTC_OK, ret);
            CPPUNIT_ASSERT(isFound(pman->get_loaded_modules(),
                                   ".//.libs/DummyModule2.so"));
        }
        catch(...)
        {
	    CPPUNIT_FAIL("Exception thrown.");
        }
        //
        try
        {
            ret = pman->unload_module(".//.libs/DummyModule2.so");
            CPPUNIT_ASSERT_EQUAL(::RTC::RTC_OK, ret);
        }
        catch(...)
        {
            CPPUNIT_FAIL( "unload error" );
        }
        //
        try
        {
            pman->unload_module("non-loaded-module.so");
	    CPPUNIT_FAIL("Exception not thrown.");
        }
        catch(...)
        {
//            CPPUNIT_FAIL( "unload error" );  //OK
        }
        delete pman;
    }
Пример #6
0
void ofxArtool5::drawDebug(){
    ofPushStyle();
    if(isFound()){
        ofSetColor(ofColor::green);
        ofDrawBitmapString("marker FOUND", 20, 20);
        ofSetColor(ofColor::yellow);
        ofFill();
        ARMarkerInfo marker = getSelectedMarker();
        ofVec2f ctr = getMarkerCenter(marker);
        ofDrawCircle(ctr.x,ctr.y,10);
        ofSetLineWidth(3);
        ofNoFill();
        ofBeginShape();
        for(int i=0;i<4;i++){
            ofVec2f vv = getMarker2DPoint(marker, i);
            ofVertex(vv.x,vv.y);
        }
        ofEndShape(true);
        ofSetLineWidth(1);
    }else{
        ofSetColor(ofColor::red);
        ofDrawBitmapString("marker NOT FOUND", 10, 10);
    }
    ofPopStyle();
    
}
Пример #7
0
/**
** Function to delete the requested node
**/   
int deleteFunc(struct myHashTable hashTable[], int key, int hashSize){
	
	if(isFound(hashTable, key, hashSize)){
		printf("\tFound the element, key: %d, going to delete the same. \n",key);

		int hashBucket=myHashFunc(key, hashSize);
		struct myNode *temp=hashTable[hashBucket].first, *trav=temp;

		while(temp->key != key){
			trav=temp;
			temp=temp->next;
		}	
		
		if(temp == trav)
			hashTable[hashBucket].first=hashTable[hashBucket].first->next;
		else
			trav->next=temp->next;
		
		printf("\tAbout to delete the node with key: %d and name: %s\n",temp->key,temp->name);		

		temp=NULL;
		free(temp);
		printf("\tDeleted successfully.\n \n");
	}
	else
		printf("\tElement not found\n \n");	

	return 0;
}
Пример #8
0
StatusCode TrackTune::execute()
{

  // output tuple
  Tuple myTuple = nTuple("Candidates");

  const LHCb::Track::Range tracks = get<LHCb::Track::Range>(m_trackLocation);
  const LHCb::Particle::Range particles = get<LHCb::Particle::Range>(m_particleLocation);

  std::vector<const LHCb::Particle* > tVec; 
  if (select(tVec,particles) == false) return StatusCode::SUCCESS ;

  for (std::vector<const LHCb::Particle* >::const_iterator iterP = tVec.begin(); iterP != tVec.end(); ++iterP ){

    bool rec = isFound(tracks,**iterP);
    myTuple <<  Tuples::Column("M", (*iterP)->measuredMass()) 
            <<  Tuples::Column("found",rec) 
	    <<  Tuples::Column("PT", (*iterP)->pt())
            <<  Tuples::Column("Candidates", particles.size());

    myTuple->write();
  }

  return StatusCode::SUCCESS ;
  //
} // the end of the Algorihtm
void SingleTracker::handleBrowserEvent(eyetracker_browser::event_type type, eyetracker_info::pointer et_info)
{
    if (et_info->get_product_id() == m_pid)
    {
        if (type == eyetracker_browser::TRACKER_FOUND || type == eyetracker_browser::TRACKER_UPDATED)
        {
            m_info = et_info;
            emit isFoundChanged(isFound());
        }
        else
        {
            m_info.reset();
            emit isFoundChanged(isFound());
        }
    }
}
Пример #10
0
size_t strlenNEON(const char *p)
{
	const char *const top = p;
	uint8x16_t c16 = vdupq_n_u8(0);
	/* 16 byte alignment */
	size_t n = reinterpret_cast<size_t>(p) & 15;
	if (n > 0) {
		uint8x16_t x = *(const uint8x16_t*)&p[-n];
		uint8x16_t a = vceqq_u8(x, c16);
		unsigned long mask = GetByteMask(a) << (16 + n);
		if (mask) {
			return __builtin_clz(mask);
		}
		p += 16 - n;
	}
	assert((reinterpret_cast<size_t>(p) & 15) == 0);
	for (;;) {
		uint8x16_t x = *(const uint8x16_t*)&p[0];
		uint8x16_t a = vceqq_u8(x, c16);

		if (isFound(a)) {
 			unsigned int mask = GetByteMask(a);
			return p + __builtin_clz(mask) - top;
		}
		p += 16;
	}
}
Пример #11
0
	bool exist(vector<vector<char> > &board, string word) {
		if (board.size() <= 0 || board[0].size() <= 0) return word.length() == 0;
		for (int x = 0; x < board.size(); x++)
			for (int y = 0; y < board[0].size(); y++)
				if (isFound(board, word, x, y, 0))
					return true;
		return false;
	}
Пример #12
0
bool exist(char** board, int row, int col, char* word) 
{
    for(int i = 0; i < row; i++)
        for(int j = 0; j < col; j++)
            if(isFound(board, row, col, word, i, j))
                return true;
    return false;
}
    /*! 
     * @brief tests for get_loaded_modules()
     *
     *
     *
     */
    void test_get_loaded_modules()
    {
        ::RTM::ManagerServant *pman = new ::RTM::ManagerServant();
        ::RTC::ReturnCode_t ret;
        try
        {
            ret = pman->load_module(".libs/DummyModule1.so","DummyModule1Init");
            CPPUNIT_ASSERT_EQUAL(::RTC::RTC_OK, ret);
            CPPUNIT_ASSERT(isFound(pman->get_loaded_modules(), 
                                   ".//.libs/DummyModule1.so"));
        }
        catch(...)
        {
	    CPPUNIT_FAIL("Exception thrown.");
        }
        try
        {
            ret = pman->load_module(".libs/DummyModule2.so","DummyModule2Init");
            CPPUNIT_ASSERT_EQUAL(::RTC::RTC_OK, ret);
            CPPUNIT_ASSERT(isFound(pman->get_loaded_modules(), 
                                   ".//.libs/DummyModule2.so"));
        }
        catch(...)
        {
	    CPPUNIT_FAIL("Exception thrown.");
        }

        //Execute the function
        ::RTM::ModuleProfileList* list;
        list = pman->get_loaded_modules();
        ::RTM::ModuleProfileList modlist(*list);
        delete list;

        //Check returns(ModuleProfileList).
        CPPUNIT_ASSERT_EQUAL((::CORBA::ULong)2, modlist.length());
        CPPUNIT_ASSERT_EQUAL(::std::string("file_path"), 
                             ::std::string(modlist[0].properties[0].name));
        const char* ch;
        if( modlist[0].properties[0].value >>= ch )
        {
            CPPUNIT_ASSERT_EQUAL(::std::string(".//.libs/DummyModule1.so"), 
                                 ::std::string(ch));
        }
        else
        {
Пример #14
0
bool Solution::exist(vector<vector<char> > &board, string word)
{
	m=board.size();
	n=board[0].size();
	for(int x=0;x<m;x++)
		for(int y=0;y<n;y++)
		{
			if(isFound(board,word.c_str(),x,y))
				return true;
		}
	return false;
}
Пример #15
0
//--------------------------------------------------------------
string ofxOpenNIUser::getDebugInfo(){
    ostringstream info;
    info << "XnUserID: " << ofToString(XnID) << " ";
    info << "autoCalibrate: " << boolToString(bUseAutoCalibration) << " ";
    info << "isFound: " << boolToString(isFound()) << " ";
    info << "isTracking: " << boolToString(isTracking()) << " ";
    info << "isSkeleton: " << boolToString(isSkeleton()) << " ";
    info << "isCalibrating: " << boolToString(isCalibrating()) << endl;
    info << "useMaskPixels: " << boolToString(getUseMaskPixels()) << " ";
    info << "useMaskTexture: " << boolToString(getUseMaskTexture()) << " ";
    info << "usePointCloud: " << boolToString(getUsePointCloud()) << " ";
    if (bUsePointCloud) {
        info << "pointCloudDrawSize: " << ofToString(pointCloudDrawSize) << " ";
        info << "pointCloudResolution: " << ofToString(pointCloudResolution) << " ";
    }
    return info.str();
}
    void FeaturesTracker::draw(){
               
        ofPushStyle();
        
        ofSetColor(ofColor::red);
        drawQueryPoints();
        drawImgKeyPoints();
        

        
        if(isFound()){
            ofSetColor(ofColor::white);
            drawMatches();
            ofSetColor(ofColor::yellow);
            drawQuad();
            
        }
        
        ofPopStyle();
    }
Пример #17
0
inline bool isFound2(uint8x16_t a, uint8x16_t b) 
{
	return isFound(vorrq_u8(a, b));
}