Esempio n. 1
0
void AAStar::tracePath(ANode* x, std::list<ANode*>& path) {
	while (x != start) {
		path.push_front(x);
		x = x->parent;
	}
	path.push_front(start);
}
Esempio n. 2
0
//Encontra o menor caminho até o objetivo
void mazeProcessing::encontra_menor_caminho(int* pos_obj, int** mapa_distancias, int** paredes, std::list<int> &caminho_x, std::list<int> &caminho_y)
{
	caminho_y.push_front(pos_obj[0]);
	caminho_x.push_front(pos_obj[1]);

    int pos_atual[2], pos_prox[2];
	pos_atual[0] = pos_obj[0];
	pos_atual[1] = pos_obj[1];
    while(mapa_distancias[pos_atual[0]][pos_atual[1]] != 0)
    {
    	int j = -1;
    	for(int i = 0; i < 4; i++)
		{
			pos_prox[0] = pos_atual[0] + (i / 2) * j;
			pos_prox[1] = pos_atual[1] + ((3 - i) / 2) * j;
			if(verifica_conexao(pos_atual, pos_prox, paredes))
		    	if(mapa_distancias[pos_prox[0]][pos_prox[1]] == mapa_distancias[pos_atual[0]][pos_atual[1]] - 1)
		    	{
		    		caminho_y.push_front(pos_prox[0]);
		    		caminho_x.push_front(pos_prox[1]);
		    		pos_atual[0] = pos_prox[0];
		    		pos_atual[1] = pos_prox[1];
		    		break;
		    	}
		    j *= -1;
		}
    }
}
void TranslationTableItem::clear(std::list<TranslationPage*> &pages) {
  //if (mips32) {
    //pages.push_front(static_cast<TranslationPage*>(mips32));
    //mips32 = NULL;
  //}
  //if (mips64) {
    //pages.push_front(static_cast<TranslationPage*>(mips64));
    //mips64 = NULL;
  //}
  if (arm32) {
    pages.push_front(static_cast<TranslationPage*>(arm32));
    arm32 = NULL;
  }
  if (thumb) {
    pages.push_front(static_cast<TranslationPage*>(thumb));
    thumb = NULL;
  }
  if (arm_v6) {
    pages.push_front(static_cast<TranslationPage*>(arm_v6));
    arm_v6 = NULL;
  }
  if (thumb_v6) {
    pages.push_front(static_cast<TranslationPage*>(thumb_v6));
    thumb_v6 = NULL;
  }
  //if (ppc) {
    //pages.push_front(static_cast<TranslationPage*>(ppc));
    //ppc = NULL;
  //}
}
Esempio n. 4
0
/**
 * Returns by reference the list of new and ceased collisions
 *  that will be the objects of ONENTER and ONEXIT events.
 */
void BulletWorld::listCollisions(std::list <ContactPoint> &contactPoints) {

/*
 * Creates a list of all the current collisions on the World
 * */
    std::map<std::pair<long,long>, ContactPoint> currCollisions;
    int numManifolds = mPhysicsWorld->getDispatcher()->getNumManifolds();
    btPersistentManifold *contactManifold;

    for (int i = 0; i < numManifolds; i++) {
        ContactPoint contactPt;

        contactManifold = mPhysicsWorld->getDispatcher()->
                getManifoldByIndexInternal(i);

        contactPt.body0 = (BulletRigidBody *) (contactManifold->getBody0()->getUserPointer());
        contactPt.body1 = (BulletRigidBody *) (contactManifold->getBody1()->getUserPointer());
        contactPt.normal[0] = contactManifold->getContactPoint(0).m_normalWorldOnB.getX();
        contactPt.normal[1] = contactManifold->getContactPoint(0).m_normalWorldOnB.getY();
        contactPt.normal[2] = contactManifold->getContactPoint(0).m_normalWorldOnB.getZ();
        contactPt.distance = contactManifold->getContactPoint(0).getDistance();
        contactPt.isHit = true;

        std::pair<long, long> collisionPair((long)contactPt.body0, (long)contactPt.body1);
        std::pair<std::pair<long, long>, ContactPoint> newPair(collisionPair, contactPt);
        currCollisions.insert(newPair);

        /*
         * If one of these current collisions is not on the list with all the previous
         * collision, then it should be on the return list, because it is an onEnter event
         * */
        auto it = prevCollisions.find(collisionPair);
        if ( it == prevCollisions.end()) {
            contactPoints.push_front(contactPt);
        } 
        contactManifold = 0;
    }

    /*
     * After going through all the current list, go through all the previous collisions list,
     * if one of its collisions is not on the current collision list, then it should be
     * on the return list, because it is an onExit event
     * */
    for (auto it = prevCollisions.begin(); it != prevCollisions.end(); ++it) {
        if (currCollisions.find(it->first) == currCollisions.end()) {
            ContactPoint cp = it->second;
            cp.isHit = false;
            contactPoints.push_front(cp);
        }
    }

/*
 * Save all the current collisions on the previous collisions list for the next iteration
 * */
    prevCollisions.clear();
    prevCollisions.swap(currCollisions);

}
Esempio n. 5
0
void FlipMemo::altCodes(const ResBlk& rblk,	bool useXplorNames, bool useOldNames, bool bbModel, 
						std::list<char>& sch) {
	char ch, buf[10];
	int rt = 0, k = 0, cursor = 0;
	bool isInResidueSet = FALSE, dupalt = FALSE;

	const char *resname = rblk.firstRec().resname();

	for(rt = 0; _resFlip[rt].rname; rt++) {
	        if ( (strcmp(_resFlip[rt].rname, resname) == 0)
	      		&& !(((_resFlip[rt].flags & USEOLDNAMES) && ! useOldNames)
	        	|| ((_resFlip[rt].flags & XPLORNAME)  && ! useXplorNames)
	        	|| ((_resFlip[rt].flags & USENEWNAMES) && (useOldNames || useXplorNames))) ) {
			isInResidueSet = TRUE;
			break; // residue type is one of those we are concerned with
		}
	}
	if (isInResidueSet) {
		std::multimap<std::string, PDBrec*> pdb = rblk.atomIt();
		std::string key;
		std::multimap<std::string, PDBrec*>::const_iterator pdbit = pdb.begin();
		PDBrec* atsq = NULL;
		while(pdbit != pdb.end()) {
			key = pdbit->first;
			for (; pdbit != pdb.end() && pdbit->first == key; ++pdbit) {
				atsq = pdbit->second;
				bool foundname = FALSE;
				for(int i=_resFlip[rt].fromScat;
				i < _resFlip[rt].fromScat+_resFlip[rt].numScat; i++) {

					if (strcmp(_pointName[rt][i], atsq->atomname()) == 0) {
						foundname = TRUE;
						break;
					}
				}
				if (foundname) {
					ch = toupper(atsq->alt());
					if (ch != ' ') {
						dupalt = FALSE;
						for(k = 0; k < cursor; k++) {
							if (ch == buf[k]) { dupalt = TRUE; break; }
						}
						if (! dupalt) {
							buf[cursor++] = ch;
						}
					}
				}
			}
		}
		if (cursor < 1) { sch.push_front(' '); } // no alt codes
		else {
			for(k = 0; k < cursor; k++) { // at least one alt code
				sch.push_front(buf[k]);
			}
		}
	}
}
Esempio n. 6
0
void PtrAnal::
ProcessMod(AstInterface& fa, const std::string& readname, 
          std::list<std::string>& fields, const AstNodePtr& mod)
{
  std::string modname;
  AstNodePtr p = mod;
  if (fa.IsVarRef(mod) || fa.IsArrayAccess(mod, &p)) {
      modname = Get_VarName(fa,p);
      Stmt stmt_last = fields.size()?
                      field_x_eq_y(modname, fields, readname)
                     : x_eq_y(modname, readname);
      stmts_pushback(stmts,stmt_last);
      namemap[mod.get_ptr()] = VarRef(stmt_last,modname);
  }
  else {
     AstInterface::OperatorEnum op;
     AstNodePtr p2;
     if (fa.IsUnaryOp(mod,&op, &p) && op == AstInterface::UOP_DEREF) {
            std::string lhs = Get_VarName(fa,p); 
            Stmt stmt_last  = deref_x_eq_y(lhs, fields, readname); 
            stmts_pushback(stmts,stmt_last);
            namemap[p.get_ptr()] = VarRef(stmt_last,lhs);
            namemap[mod.get_ptr()] = VarRef(stmt_last, readname);
     }
    else if (fa.IsBinaryOp(mod,&op,&p,&p2)) { 
         if (op==AstInterface::BOP_DOT_ACCESS) {
            std::string field = Local_GetFieldName(fa, p2);
            fields.push_front(field);
            ProcessMod(fa, readname, fields, p);
            Stmt stmt_last = stmts_back(stmts);
            namemap[mod.get_ptr()] = VarRef(stmt_last, readname);
         }
         else if (op==AstInterface::BOP_ARROW_ACCESS) {
            std::string lhs = Get_VarName(fa, p), field = Local_GetFieldName(fa, p2);
            fields.push_front(field);
            Stmt stmt_last  = deref_x_eq_y(lhs,fields,readname);
            stmts_pushback(stmts,stmt_last);
            namemap[p.get_ptr()] = VarRef(stmt_last,lhs);
            namemap[mod.get_ptr()] = VarRef(stmt_last, readname);
         }
         else {
            std::cerr << "can't handle " << AstToString(mod) << "\n";
            assert(false); // other operations? to be handled later  
         }
     }
     else if (fa.IsFunctionCall(mod)) {
         std::string lhs = Get_VarName(fa, mod);
         Stmt stmt_last = deref_x_eq_y(lhs, fields, readname);
         stmts_pushback(stmts,stmt_last);
         namemap[mod.get_ptr()] = VarRef(stmt_last,lhs);
     }
     else {
       std::cerr << "cannot process " << AstToString(mod) << "\n";
       assert(false); // other operations? to be handled later  
    }
  }
}
Esempio n. 7
0
/**
 * \brief Get the items concerned by a progress/move of this one.
 * \param d (out) A list to which are added such items.
 */
void bear::bridge::get_dependent_items( std::list<physical_item*>& d ) const
{
  items_list_const_iterator it;
  
  for( it=m_items.begin(); it!=m_items.end(); ++it )
    if ( it->get_item().get() != NULL ) 
      d.push_front( it->get_item().get() );

  d.push_front(m_top_left_ref);
  d.push_front(m_top_right_ref);
} // bridge::get_dependent_items()
Esempio n. 8
0
void GridWorldProblem::addSuccessor(
    GridWorldState* state, std::list<mlcore::Successor>& successors,
    int val, int limit, int newx, int newy, double prob)
{
    bool isWall = (walls.count(std::pair<int, int> (newx, newy)) != 0);
    if (val > limit && !isWall) {
        GridWorldState *next = new GridWorldState(this, newx, newy);
        successors.push_front(mlcore::Successor(this->addState(next), prob));
    } else {
        successors.push_front(mlcore::Successor(state, prob));
    }
}
void ActiveProducer::copyDefaultProperties(	ActiveMessage& activeMessage,
											ActiveLink& activeLink,
											std::list<std::string>& defaultKeysList)
	throw (ActiveException){

	std::stringstream logMessage;

	std::string key;
	try{
		//looping through default properties and inserting into activeMessage
		for (int it=0; it<activeLink.getPropertySize();it++){
			Parameter* property=activeLink.getProperty(it,key);
			switch (property->getType()){
			case ACTIVE_INT_PARAMETER:{
				IntParameter* intProperty=(IntParameter*)property;
				try{
					activeMessage.insertIntProperty(key,intProperty->getValue());
					defaultKeysList.push_front(key);
				}catch (ActiveException& ae){
					throw ae;
				}
			}
			break;
			case ACTIVE_REAL_PARAMETER:{
				RealParameter* realProperty=(RealParameter*)property;
				try {
					activeMessage.insertRealProperty(key,realProperty->getValue());
					defaultKeysList.push_front(key);
				}catch (ActiveException& ae){
					throw ae;
				}
			}
			break;
			case ACTIVE_STRING_PARAMETER:{
				StringParameter* stringProperty=(StringParameter*)property;
				try{
					activeMessage.insertStringProperty(key,stringProperty->getValue());
					defaultKeysList.push_front(key);
				}catch (ActiveException& ae){
					throw ae;
				}
			}
			break;
			}
		}
	}catch (ActiveException& ae){
		logMessage << "ERROR. Cannot copy default properties to message" << ae.getMessage();
		throw ActiveException(logMessage.str());
	}
}
Esempio n. 10
0
inline void Observer::registerWith(
    const boost::shared_ptr<Observable>& h) {
    if (h) {
        observables_.push_front(h);
        h->registerObserver(this);
    }
}
		void grow(void){
			Cord c;
			c.x  = cords.front().x;
			c.y  = cords.front().y;
			switch (direction) {
				case LEFT:
					if (c.x == 0) {
						c.x = MAX_X;
						if (c.y == 0) c.y = MAX_Y;
						c.y-=1;
					}
					c.x-=1;
					break;
				case RIGHT:
					if (c.x == MAX_X) {
						c.x = 0;
						if (c.y == MAX_Y) c.y = 0;
						c.y+=1;
					}
					c.x+=1;
					break;
				case UP:
					if (c.y == 0) c.y = MAX_Y;
					c.y-=1;
					break;
				case DOWN:
					if (c.y == MAX_Y) c.y = 0;
					c.y+=1;
					break;
			}
			cords.push_front(c);
		}
Esempio n. 12
0
bool Graph::visit(int v, std::list<int> & sortedList)
{
    VertexIterator iter = vertices.find(v);
    if (iter != vertices.end())
    {
        if (iter->second.visited == false)
        {
            iter->second.visited = true;

            std::list<Edge>::const_iterator liter = iter->second.adjList.begin();
            for (; liter != iter->second.adjList.end(); ++liter)
            {
                if (!visit(liter->dest, sortedList))
                {
                    return false;
                }
            }
            sortedList.push_front(iter->first);
        }
        else
        {
            return false;
        }
    }
    return true;
}
Esempio n. 13
0
static void de_robv_android_xposed_XposedBridge_hookMethodNative(JNIEnv* env, jclass clazz, jobject declaredClassIndirect, jint slot) {
    // Usage errors?
    if (declaredClassIndirect == NULL) {
        dvmThrowIllegalArgumentException("declaredClass must not be null");
        return;
    }
    
    // Find the internal representation of the method
    ClassObject* declaredClass = (ClassObject*) dvmDecodeIndirectRef(dvmThreadSelf(), declaredClassIndirect);
    Method* method = dvmSlotToMethod(declaredClass, slot);
    if (method == NULL) {
        dvmThrowNoSuchMethodError("could not get internal representation for method");
        return;
    }
    
    if (findXposedOriginalMethod(method) != xposedOriginalMethods.end()) {
        // already hooked
        return;
    }
    
    // Save a copy of the original method
    xposedOriginalMethods.push_front(*((MethodXposedExt*)method));

    // Replace method with our own code
    SET_METHOD_FLAG(method, ACC_NATIVE);
    method->nativeFunc = &xposedCallHandler;
    method->registersSize = method->insSize;
    method->outsSize = 0;

    if (PTR_gDvmJit != NULL) {
        // reset JIT cache
        MEMBER_VAL(PTR_gDvmJit, DvmJitGlobals, codeCacheFull) = true;
    }
}
Esempio n. 14
0
int main ()
{
	scanf("%d %d",&ilosc_kolumn,&ilosc_wierszy);
	for(int licznikW = 0; licznikW <ilosc_wierszy; licznikW++) {
		scanf("%s",&tablicaWK[licznikW]);
		for(int licznikK = 0; licznikK < ilosc_kolumn; licznikK++) {
			if (tablicaWK[licznikW][licznikK] == POSZUKIWACZ) {
				poszukiwacz.nr_wiersza = licznikW;
				poszukiwacz.nr_kolumny = licznikK;
				poszukiwacz.ojciec = BRAK;
			} else if (tablicaWK[licznikW][licznikK] == SKARB) {
				skarb.nr_wiersza = licznikW;
				skarb.nr_kolumny = licznikK;
			}			
		}
	}

	/*KONIEC POBIERANIA DANYCH*/
	lista_wpolrzednych.push_front(poszukiwacz);
	
	minimalna_ilosc_krokow = 0;
	int kod_wyjscia = 0;
	do
	{
		minimalna_ilosc_krokow++; 
		kod_wyjscia = petla(minimalna_ilosc_krokow);
		if (kod_wyjscia == KONIEC_SZUKANIA) {
			printf("%s",SLOWO_NIE);
			return 0;
		}
	} while(kod_wyjscia == 0);
	printf("%d", kod_wyjscia);
	return 0;
}
double MinCirclePoints(double &mincx, double &mincy,
                       std::list <std::list<wxRealPoint> > &all_points,
                       std::vector<wxRealPoint> &points)
{
    if(all_points.size() == 0)
        return MinCircle(mincx, mincy, points);

    std::list<wxRealPoint> cpoints = all_points.front();
    all_points.pop_front();

    int s =  points.size();
    points.push_back(wxRealPoint());
    double mind = INFINITY;
    for(std::list<wxRealPoint>::iterator it = cpoints.begin();
        it != cpoints.end(); it++) {
        points[s] = *it;

        double cx, cy, cd;
        cd = MinCirclePoints(cx, cy, all_points, points);
        if(cd < mind) {
            mind = cd;
            mincx = cx;
            mincy = cy;
        }
    }
    points.pop_back();
    all_points.push_front(cpoints);

    if(isinf(mind))
        return NAN;
    return mind;
}
Esempio n. 16
0
void addToList( container &c ) {
	c.time = c.fixed_time;
	c.time += time_passed;
	if( time_passed > c.time ) {
		// reset time_passed
		for( auto &e : time_list ) {
			e.time -= time_passed;
		}
		time_passed = 0;
	}

	if( time_list.size() > 0 ) {
		// find place to insert
		bool found = false;
		for( auto it = time_list.begin(); it != time_list.end(); it++ ) {
			if( it->time > c.time ) {
				time_list.insert( it, c );
				found = true;
				break;
			}
		}
		if( !found )
			time_list.push_back( c );
	} else {
		time_list.push_front( c );
	}
}
Esempio n. 17
0
bool gTraceJointsBackward(GJoint *pEndJoint_, GBody *pLeftBodyOfEndJoint_, std::list<GJoint *> &pTracedJoints_)
{
	GJoint *pjoint;
	std::list<GJoint *>::iterator iter_pjoint;

	pTracedJoints_.clear();

	if ( pEndJoint_ == NULL ) return false;

	pjoint = pEndJoint_;

	while (1) {

		if ( pjoint->pLeftBody == pLeftBodyOfEndJoint_ ) { break; }

		for (iter_pjoint = pjoint->pLeftBody->pJoints.begin(); iter_pjoint != pjoint->pLeftBody->pJoints.end(); iter_pjoint++) {
			if ( *iter_pjoint != NULL && !(*iter_pjoint)->isCut() && (*iter_pjoint)->pRightBody == pjoint->pLeftBody ) {
				pTracedJoints_.push_front(*iter_pjoint);
				break;
			}
		}

		if ( iter_pjoint == pjoint->pLeftBody->pJoints.end() ) { return false; }

		pjoint = *iter_pjoint;
	}

	pTracedJoints_.push_back(pEndJoint_);

	return true;
}
Esempio n. 18
0
	void update(api_message e) {
		m_list.push_front(e);
		if (m_bufferSize != -1)
			while (m_list.size() > m_bufferSize)
				m_list.pop_back();
		dumpInFile();
	}
Esempio n. 19
0
void Log::log(std::string msg) {
    std::lock_guard<std::mutex> lck(s_lock);

    msg.resize(s_msgLen, ' ');
    s_messages.pop_back();
    s_messages.push_front(msg);
}
Esempio n. 20
0
	/**
	 * load shader from file and attach shader to program
	 */
	bool attachShader(const char *shader_file, GLuint type)
	{
		// insert new shader at begin of texture
		CGlShader tmp_shader;
		shaders.push_front(tmp_shader);

		CGlShader &new_shader = shaders.front();
		new_shader.init(type);
		if (!new_shader.loadSource(shader_file, prefix_string))
		{
			std::cerr << "Load error in shader_file " << shader_file << std::endl;
			std::cerr << new_shader.getInfoLog() << std::endl;
			error = true;
			// call deconstructor and remove
			shaders.pop_front();
			return false;
		}

		if (!new_shader.compile())
		{
			std::cerr << "Compile error in shader_file " << shader_file << std::endl;
			std::cerr << new_shader.getInfoLog() << std::endl;
			error = true;

			// call deconstructor and remove
			shaders.pop_front();
			return false;
		}

		glAttachShader(program, new_shader());

		return true;
	}
Esempio n. 21
0
//============================================================================
static void QueueOp (NlmOp * op, bool front = false) {
    if (front) {
        s_opqueue.push_front(op);
    } else {
        s_opqueue.push_back(op);
    }
}
Esempio n. 22
0
SDL_Surface* QuickSaveImageCache::get(std::string image_name) {
    std::map<std::string, cache_iter_t>::iterator it = m_images.find(image_name);
    if (it != m_images.end()) {
        // found it: move to front of list
        m_used.splice(m_used.begin(), m_used, it->second);
        return it->second->second;
    }
    
    // didn't find: load image
    FileSpecifier f;
    f.SetToQuickSavesDir();
	f.AddPart(image_name + ".sgaA");
	
	WadImageDescriptor desc;
	desc.file = f;
	desc.checksum = 0;
	desc.index = SAVE_GAME_METADATA_INDEX;
	desc.tag = SAVE_IMG_TAG;
	
	SDL_Surface *img = WadImageCache::instance()->get_image(desc, PREVIEW_WIDTH, PREVIEW_HEIGHT);
	if (img) {
        m_used.push_front(cache_pair_t(image_name, img));
        m_images[image_name] = m_used.begin();
        
        // enforce maximum cache size
        if (m_used.size() > k_max_items) {
            cache_iter_t lru = m_used.end();
            --lru;
            m_images.erase(lru->first);
            SDL_FreeSurface(lru->second);
            m_used.pop_back();
        }
    }
    return img;
}
Esempio n. 23
0
void UpdatePrimitiveSelection (IPrimitiveEditor *primitiveEditor, CDatabaseLocatorPointer &locator, bool &modified)
{
	// Is selected ?
//	IProperty *prop;
	if (getPrimitiveEditor(locator.Primitive)->getSelected())
//	if (locator.Primitive->getPropertyByName ("selected", prop))
	{
		// In the list ?
		if (primitiveEditor->_SelectionIterator == Selection.end ())
		{
			// Add it to the selection list
			Selection.push_front (const_cast<IPrimitive*> (locator.Primitive));

			// Get the iterator
			primitiveEditor->_SelectionIterator = Selection.begin ();
			modified = true;
		}
	}
	else
	{
		// In the list ?
		if (primitiveEditor->_SelectionIterator != Selection.end ())
		{
			// Remove it
			primitiveEditor->removeFromSelection ();
			modified = true;
		}
	}
}
Esempio n. 24
0
 bool get(std::list<ElemType>& elem, std::list<CountType>& count)
 {
     BucketT* bp = bs_->next_;
     while(bp)
     {
         ItemT* i=bp->head_;
         while(i)
         {
             elem.push_front(i->elem_);
             count.push_front(i->b_->c_);
             i=i->next_;
         }
         bp=bp->next_;
     }
     return true;
 }
Esempio n. 25
0
void AutoexecObject::InstallBefore(const std::string &in) {
	if(GCC_UNLIKELY(installed)) E_Exit("autoexec: allready created %s",buf.c_str());
	installed = true;
	buf = in;
	autoexec_strings.push_front(buf);
	this->CreateAutoexec();
}
void
avtScalarMetaData::ComboDigitsFromVal(double id, int n, int maxr,
    const std::vector<std::vector<int> > &ptMap, std::list<int> &digits)
{
    int row, col, grp;

    for (grp = 1; grp <= maxr; grp++)
    {
        double grpc = NChooseR(n,grp);
        if (id < grpc)
            break;
        else
            id -= grpc;
    }
    if (grp == maxr+1)
        return;

    int rowmin = 0;
    for (col = grp-1; col >= 0; col--)
    {
        for (row = rowmin; row < n; row++)
        {
            int seglen = ptMap[row][col];
            if (id < seglen)
            {
                rowmin = row+1;
                digits.push_front(row);
                break;
            }
            id -= seglen;
        }
    }
}
Esempio n. 27
0
Direction MaxOfFewSearch::move(GameState& state, int ms
#ifdef DEBUG
							   , std::list<Direction>& moveSequence
#endif
  							  )
{
	Direction bestMove = DIR_END;
	double bestValue = -std::numeric_limits<double>::infinity();
	for(int i = 0; i < k_ || bestMove == DIR_END; ++i)
	{
		Direction direction = rand() % DIR_END;
		if(!state.canMove(direction))
			continue;
		
		state.move(direction);
		double value = heuristic_(state);
		state.undo(direction);
		
		if(value > bestValue || bestMove == DIR_END)
		{
			bestMove = direction;
			bestValue = value;
		}
	}
	
#ifdef DEBUG
	moveSequence.clear();
	moveSequence.push_front(bestMove);
#endif
	
	return bestMove;
}
Esempio n. 28
0
/* insert_and_merge
   Inserts a new set into a list of sets, but merges any sets 
   which now have a non-empty intersection with the addition 
   of the new set. This maintains a completely disjuctive set of sets in 
   listOfSets. 
   
   We do this by looping over listOfSets and checking the intersection of 
   the new set with a given set. 
   -- If it's empty, then the labels in the two sets are not 
      equivalent (as far as we know) so we continue to the next 
      set in the list.
   -- If it's not empty then all labels in both sets are 
      equivalent, so we remove the tested set from the list, and 
      form the union of this with the current labels.
*/
void insert_and_merge(std::set<Label>& newSet, 
    std::list< std::set<Label> >& listOfSets) 
{
    // Every time we make changes we want to re-iterate to capture all 
    // equivalent sets in list.
    bool madeChanges = true;
    while (madeChanges) {
        madeChanges = false; 
        // Iterate through listOfSets, checking for intersection with newSet
        std::list< std::set<Label> >::iterator listIter = listOfSets.begin(); 
        while (listIter != listOfSets.end()) {
            bool intersectionExists = do_sets_intersect(\
               newSet.begin(), newSet.end(), 
               listIter->begin(), listIter->end()); 
            if (intersectionExists) { 
               // If intersection is not empty, remove current set from the 
               // list and merge it with the newSet. Note that list::erase
               // returns an incremented pointer.
               std::set<Label>::const_iterator setIter = listIter->begin();
               while (setIter != listIter->end())
                   newSet.insert(*setIter++);
               listIter = listOfSets.erase(listIter);
               madeChanges = true;
            } else {
               // Otherwise increment the list iterator
               listIter++;
            }
        }         
    }

    // Add newly merged set back into list
    listOfSets.push_front(newSet);                                           
}
Esempio n. 29
0
static void miui_dexspy_DexspyInstaller_hookMethodNative(JNIEnv* env, jclass clazz, jobject declaredClassIndirect, jint slot) {
    // Usage errors?
    if (declaredClassIndirect == NULL) {
        dvmThrowIllegalArgumentException("declaredClass must not be null");
        return;
    }

    // Find the internal representation of the method
    ClassObject* declaredClass = (ClassObject*) dvmDecodeIndirectRef(dvmThreadSelf(), declaredClassIndirect);
    Method* method = dvmSlotToMethod(declaredClass, slot);
    if (method == NULL) {
        dvmThrowNoSuchMethodError("could not get internal representation for method");
        return;
    }

    if (findOriginalMethod(method) != dexspyOriginalMethods.end()) {
        ALOGD("why this method already hooked: %s:%s(%s)", method->clazz->descriptor, method->name, method->shorty);
        // already hooked
        return;
    }

    // Save a copy of the original method
    dexspyOriginalMethods.push_front(*method);

    // Replace method with our own code
    SET_METHOD_FLAG(method, ACC_NATIVE);
    method->nativeFunc = &dexspyCallHandler;
    method->registersSize = method->insSize;
    method->outsSize = 0;
    #ifdef WITH_JIT
    // reset JIT cache
    gDvmJit.codeCacheFull = true;
    #endif
}
Esempio n. 30
0
Recherche::Recherche(char * sr, std::list<MotClef>::iterator &itKey, std::list<MotClef> &listKey)
{
     char  key[1];
     char * ptok;
     ptok = (char *)malloc(10000 * sizeof(char));

     key[0]=' ';

    if (strlen(sr)< 10000 && strlen(sr)>3)
    {
        std::cout << ptok << std::endl;
        // découpage et création de la liste de keyword
        ptok = strtok(sr,key);
        itKey = listKey.begin();


        while (ptok != NULL)
        {

            listKey.push_front (MotClef(ptok));
            itKey++;
            //
            ptok = strtok(NULL,key);


        }

    }
    else
    {
        std::cout << "Erreur: Taille de Recherche" << sr << std::endl ;
    }
}