void DealWithWarp (int x, int y) {
  static bool warp_pointer = XMLSupport::parse_bool(vs_config->getVariable ("joystick","warp_mouse","false"));
  static int mouse_warp_zone = XMLSupport::parse_int(vs_config->getVariable ("joystick","warp_mouse_zone","100"));
 if (warp_pointer) {
   if (joystick[MOUSE_JOYSTICK]->player<_Universe->numPlayers()) {
    if (x<mouse_warp_zone||y<mouse_warp_zone||x>g_game.x_resolution-mouse_warp_zone||y>g_game.y_resolution-mouse_warp_zone) {
      //VSFileSystem::Fprintf (stderr,"warped from %d %d to %d %d",mousex,mousey, g_game.x_resolution/2,g_game.y_resolution/2);
      
      int delx = -x+g_game.x_resolution/2;
      int dely = -y+g_game.y_resolution/2;
      mousex+=delx;
      mousey+=dely;
      deque<MouseEvent>::iterator i;
      for (i=eventQueue.begin();i!=eventQueue.end();i++) {
	i->x+=delx;
	i->y+=dely;
      }
      if (warpallowage-->=0) {
	winsys_warp_pointer(g_game.x_resolution/2,g_game.y_resolution/2);
      }
    }
   }
  }

}
Example #2
0
void func(deque<char>& stack, int left, int right, vector<string>& result)
{
	if(left == 0 && right == 0)
	{
		result.push_back(string(stack.begin(),stack.end()));
		return;
	}

	if(left > right)
		return;
	
	if(left > 0)
	{
		stack.push_back('(');
		func(stack,left-1,right,result);
		stack.pop_back();
	}

	if(right > 0)
	{
		stack.push_back(')');
		func(stack,left,right-1,result);
		stack.pop_back();
	}
}
Example #3
0
void LogSorter::PushFilteredResults(deque<LogEntry>& filteredResultQueue)
{
	//TODO: this may have very poor performance, need to address later
	std::unique_lock<std::mutex> lock(m_mtx);
	m_resultQueue.insert(m_resultQueue.end(), filteredResultQueue.begin(), filteredResultQueue.end());;
	std::stable_sort(m_resultQueue.begin(), m_resultQueue.end(), compare_logentry);
}
Example #4
0
    void renderParticles()
    {
        glDisable(GL_LIGHTING);
        glBindTexture(GL_TEXTURE_2D, texId);

        liveParticles = 0;

        deque<cParticle>::iterator ptlIter;
        for( ptlIter = particles.begin(); ptlIter != particles.end(); ptlIter++ )
        {
            if(ptlIter->active)
            {
                glBegin(GL_TRIANGLE_STRIP);
                    glColor4f(ptlIter->r, ptlIter->g, ptlIter->b, ptlIter->life);
                    glTexCoord2d(1,1); glVertex3f(ptlIter->position.x + 0.1f, ptlIter->position.y + 0.1f, ptlIter->position.z); // Top Right
                    glTexCoord2d(0,1); glVertex3f(ptlIter->position.x - 0.1f, ptlIter->position.y + 0.1f, ptlIter->position.z); // Top Left
                    glTexCoord2d(1,0); glVertex3f(ptlIter->position.x + 0.1f, ptlIter->position.y - 0.1f, ptlIter->position.z); // Bottom Right
                    glTexCoord2d(0,0); glVertex3f(ptlIter->position.x - 0.1f, ptlIter->position.y - 0.1f, ptlIter->position.z); // Bottom Left
                glEnd();
                liveParticles ++;
            }
        }

        glEnable(GL_LIGHTING);
    }
Example #5
0
string getReferenceClass(deque<dtdclass *> & d_Class, string root){//function to find the reference class
    deque<dtdclass*>::iterator first;/*record the first position of the deque*/
    deque<dtdclass*>::iterator last;/*record the last position of the deque*/
    first = d_Class.begin();//get the begin of the deque
    last = d_Class.end();//get the end of the deque
    if(getISA(d_Class, root, root)==true){/*check the root class have any gener class*/
        root = "("+root+")+";
    }else{root = root+"+";}
    for (deque<dtdclass *>::iterator i=first; i !=last;i++){
        if(((*i)->getRef())==true && (*i)->getInHeader()==false){
            string temp;
            string ISAname;
            temp = (*i)->getname();
            ISAname = (*i)->getname();
            if(getISA(d_Class, temp, ISAname)==true){
                root = root + ", (" + ISAname + ")"; /*add the class name in to the string*/
            }
            else{
                root  = root + ", " + (*i)->getname();/*add the class name in to the string*/
            }
            if((*i)->getlevel()==1){root = root + "+";}
            else{root = root + "*";}
        }
    }
    return root;
}
Example #6
0
bool isDivByEleven(const deque<unsigned int>& number){
  if (number.size() == 1){
    if (number[0] == 0)
      return true;
    else
      return false;
  }

  bool isOdd = true;

  deque<unsigned int> odd;
  deque<unsigned int> even;

  for (deque<unsigned int>::const_iterator itr = number.begin(), endItr = number.end() ; itr != endItr; itr++, isOdd = !isOdd)
      {
	unsigned int digit = *itr;

	if (isOdd)
	  vecSum(odd, digit);
	else 
	  vecSum(even, digit);
      }
  deque<unsigned int> diff;
  if (isBigger(odd, even))
    vecDiff(odd, even, diff);
  else 
    vecDiff(even, odd, diff);

  if (isDivByEleven(diff))
    return true;
  
  return false;
}
void shuffle_cards() {
	// Check for clearing
	cards_.clear();
	// Instantiate Deck
	for(int thirteen = 1; thirteen < 14; thirteen++) {
		for(int four = 0; four < 4; four++) {
			card birthCard(thirteen, four);
			switch(birthCard.value) {
				case 11:
					birthCard.value = J;
					break;
				case 12:
					birthCard.value = Q;
					break;
				case 13:
					birthCard.value = K;
					break;
				case 1:
					birthCard.value = A;
					break;
				default:
					// The card was 2-9
					break;
			}

			cards_.push_back(birthCard);
		}
	}
	random_shuffle(cards_.begin(), cards_.end());
	// (cards_.begin(), cards_.end(), mt);
}
Example #8
0
    void tickParticles()
    {
        deque<cParticle>::iterator ptlIter;
        for( ptlIter = particles.begin(); ptlIter != particles.end(); ptlIter ++ )
        {
            if(ptlIter->life > 0)
            {
                ptlIter->position.x += ptlIter->velocity.x / 100;
                ptlIter->position.y += ptlIter->velocity.y / 100;
                ptlIter->position.z += ptlIter->velocity.z / 100;

                ptlIter->velocity.x += ptlIter->acceleration.x / 100;
                ptlIter->velocity.y += ptlIter->acceleration.y / 100;
                ptlIter->velocity.z += ptlIter->acceleration.z / 100;

                ptlIter->life -= ptlIter->fade / 100;

                if(ptlIter->position.x < limits.x1) ptlIter->position.x = limits.x2;
                if(ptlIter->position.y < limits.y1) ptlIter->position.y = limits.y2;
                if(ptlIter->position.x > limits.x2) ptlIter->position.x = limits.x1;
                if(ptlIter->position.y > limits.y2) ptlIter->position.y = limits.y1;
            }
            else
            {
                ptlIter->active = false;
            }
        }
    }
Example #9
0
IWORKPathPtr_t makeStarPath(const IWORKSize &size, const unsigned points, const double innerRadius)
{
  // user space canvas: [-1:1] x [-1:1]

  // create outer points
  const deque<Point> outerPoints = rotatePoint(Point(0, -1), points);

  // create inner points
  const double angle = etonyek_two_pi / points;
  deque<Point> innerPoints(outerPoints);
  transform(innerPoints, scale(innerRadius, innerRadius) * rotate(angle / 2));

  // merge them together
  deque<Point> pathPoints;
  assert(outerPoints.size() == innerPoints.size());
  for (deque<Point>::const_iterator itO = outerPoints.begin(), itI = innerPoints.begin();
       (itO != outerPoints.end()) && (itI != innerPoints.end());
       ++itO, ++itI)
  {
    pathPoints.push_back(*itO);
    pathPoints.push_back(*itI);
  }

  // create the path
  transform(pathPoints, scale(size.m_width, size.m_height) * scale(0.5, 0.5) * translate(1, 1));
  const IWORKPathPtr_t path = makePolyLine(pathPoints);

  return path;
}
Example #10
0
void setGeneralisation(deque<dtdclass *>& d_class, string className, string ISAname){
    string tempGeneral,fatherClass;
    deque<dtdclass*>::iterator first;/*record the first position of the deque*/
    deque<dtdclass*>::iterator last;/*record the last position of the deque*/
    if(!d_class.empty()){
        first = d_class.begin();//get the begin of the deque
        last = d_class.end();//get the end of the deque
        for (deque<dtdclass *>::iterator i=first; i!= last;i++){
            tempGeneral = (*i)->getname();
            if(tempGeneral == className){
                (*i)->setbelong_to(ISAname);//set the belong_to class name
                for(deque<dtdclass *>::iterator j=first; j!= last;j++){
                    fatherClass = (*j)->getname();
                    int amountAtt = (*j)->getAttributeAmount();
                    if(fatherClass == ISAname){//find the class, and get the attribute
                        (*j)->setlevel(1);
                        for(int tempAmount = 0; tempAmount <amountAtt; tempAmount ++){
                            attribute *newAttribute = (*j)->getattribute();
                            attribute tempAttribute;
                            strcpy(tempAttribute.att_name, newAttribute->att_name);
                            tempAttribute.isId= newAttribute->isId;
                            tempAttribute.ismulti= newAttribute->ismulti;
                            (*i)->setattribute(tempAttribute);//copy attribute from the "father" to the "son" class
                        }
                    }
                }
            }
        }
    }
}
Example #11
0
 string print()
 {
     stringstream ss;
     deque<d_t>::iterator it;
     for(it = number.begin(); it != number.end(); it++) ss << (*it);
     return(ss.str());
 }
Example #12
0
void setReferenceClass(deque<dtdclass *> & d_Class, string className){
    deque<dtdclass*>::iterator first;/*record the first position of the deque*/
    deque<dtdclass*>::iterator last;/*record the last position of the deque*/
    first = d_Class.begin();
    last = d_Class.end();
    int numberAssoication;
    for (deque<dtdclass *>::iterator i=first; i !=last;i++){
        if((*i)->getname()== className){
            if((*i)->getRef() ==true){/*find the match class and the class Ref is true than set it false*/
                (*i)->setRef(false);
                numberAssoication = (*i)->getAssociaAmount();
                for(int current=0; current<numberAssoication; current++){/*set all classes relate to this class being the not reference class*/
                        associate * tempAsso = (*i)->getassociation(current);
                        if(tempAsso->base_Max < 3 || tempAsso->to_Max < 3 ){
                        string tempAssoname =  tempAsso->tclass_name;
                        setReferenceClass(d_Class, tempAssoname);/*to find are there any class have relationship with this class*/
                        }
                }
                for(deque<dtdclass *>::iterator j = first; j!= last; j++) {
                    string belong_to; 
                    belong_to = (*j)->getbelong_to();
                    if(belong_to == (*i)->getname()){/*if the class is belong to the (*i) class, set this class is reference class*/
                        (*j)->setRef(false);
                        setReferenceClass(d_Class, (*j)->getname());/*to find are there any class is belong to this class*/
                    }
                }
            }
            
        }
    }
}
Example #13
0
void analyser::load_data(const deque<char> & buff)
{
    m_pack.clear();

    m_pack.insert( m_pack.begin(), buff.begin(),
                                    buff.end() );
}
int print_cumulative (deque<double> & kws, string file, int number_of_step) {
		
	
	
	char buffer [file.size()+1];
	cast_string_to_char(file, buffer);
	
	ofstream expout (buffer);
	sort(kws.begin(), kws.end());
	
	int step=(kws.size()-1)/number_of_step;
	step=max(step, 1);
			
	for (int i=0; i<int(kws.size()); i++) if(i%step==0)
		expout<<kws[i]<<" "<<double(i+1)/(kws.size())<<endl;
			
			
	
			
		

	return 0;


}
void ofxBlobTracker::draw(float x,float y,float w, float h) {
	// stroked rect
	ofEnableAlphaBlending();
	ofSetColor(0, 0, 0, 70);
	ofRect(x, y, w, h);
	ofSetHexColor(0xFFFFFF);
	
	ofNoFill();
	ofRect(x, y, w, h);
	
	glPushMatrix();
	glTranslatef(x, y, 0);
	ofSetColor(0,150, 0);
	
	map<int,ofVec3f>::iterator it;
	for(it = smoothedBlobs.begin(); it!=smoothedBlobs.end(); it++) {
		ofCircle((*it).second.x*w, (*it).second.y*h, 5);
		ofDrawBitmapString("id: "+ofToString((*it).first), (*it).second.x*w, (*it).second.y*h);
		blobStore.push_back((*it).second);
	}

	while(blobStore.size()>50) {
		blobStore.pop_front();
	}
	deque<ofVec2f>::iterator itr;
	for(itr = blobStore.begin(); itr!=blobStore.end(); itr++) {
		ofCircle((*itr).x*w,(*itr).y*h, 5);
	}
	glPopMatrix();
	ofFill();
	
}
Example #16
0
int main(int argc, char *argv[])
{
    for (int i=0;i<size;i++)
    {
        cin>>frequency[i];                  //?入10??值
        ptr=new node;
        ptr->key=frequency[i];
        ptr->lchild=NULL;
        ptr->rchild=NULL;
        forest.push_back(ptr);
    }//形成森林,森林中的每一棵?都是一???
 
    //?森林?建霍夫曼?
    for (int i=0;i<size-1;i++)
    {
                sort(forest.begin(),forest.end(),compare);
                ptr=new node;
                //以下代?使用下?索引?列元素,具有?在危?,使用??注意
                ptr->key=forest[0]->key+forest[1]->key;
                ptr->lchild=forest[0];
                ptr->rchild=forest[1];
                forest.pop_front();
                forest.pop_front();
                forest.push_back(ptr);
        }
    ptr=forest.front();//ptr是一?指向根的指?
    printCode(code);
    //system("pause");
   
    while (1);
    return EXIT_SUCCESS;
}
Example #17
0
File: main.cpp Project: dmh2000/hr
minq_t minq_get(deque<minq_t> &q)
{
    minq_t i;
    stable_sort(q.begin(),q.end(),[](minq_t a,minq_t b) {return a.len < b.len;});
    i = q.front();
    q.pop_front();
    return i;
}
Example #18
0
void insert(int k, int v)
{
    hash_id = lower_bound(Ks.begin(),Ks.end(),k)-Ks.begin();
    Q[hash_id].push_back(v);
    HP.push_back(mp(++ccnt, hash_id));
    push_heap(HP.begin(),HP.end());
    make_heap(HP.begin(),HP.end(), cmp());
}
Example #19
0
void insert_readyq(Event temp){
    deque<Event>::iterator eq_it = ready_queue.begin();
    while (eq_it != ready_queue.end() && temp.dynamic_p <= eq_it->dynamic_p) {
        eq_it++;
    }
    eq_it = ready_queue.insert(eq_it, temp);
    return;
}
Example #20
0
void imprime (deque<char> r){

	deque<char>::iterator it;
	for (it = r.begin(); it != r.end(); it++){
			cout << *it;
	}
	cout << endl;
}
Example #21
0
void dump(deque<int> & container)
{
    for (deque<int>::iterator iter = container.begin(); iter != container.end(); iter++)
    {
        cout << *iter << " ";
    }
    cout << endl;
}
Example #22
0
void insert_rq(Event temp){ //insert end process into result queue
    deque<Event>::iterator rq_it = result_queue.begin();
    while (rq_it != result_queue.end() && temp.p.id > rq_it->p.id) {
        rq_it++;
    }
    rq_it = result_queue.insert(rq_it, temp);
    return;
}
Example #23
0
int found(int x)
{
	deque<int>::iterator it;
	for (it = mem.begin(); it != mem.end(); it++)
		if (*it == x)
			return 1;
	return -1;
}
Example #24
0
void print_deck(deque<int> deck){
    deque<int>::iterator it;

    for(it=deck.begin(); it != deck.end(); it++){
        cout << *it << " ";
    }
    cout << endl;
}
Example #25
0
void put_deque(deque<int> Mydeque,char *name){
	deque<int>::iterator pdeque;
	cout<<"the contents of "<<name<<" : ";
	for(pdeque=Mydeque.begin();pdeque!=Mydeque.end(); pdeque++){
		cout<<*pdeque<<" ";
	}
	cout<<endl;
}
//Function used to check if a node is already on the open or the closed list and then return the cost of that node.
//This will be used to determine whether to update the values of a node if it has already been visited.
int GetCost(deque <unique_ptr < SCoords > > &openList, deque <unique_ptr < SCoords > > &closedList, SCoords node)
{
	for (auto p = openList.begin(); p != openList.end(); p++)
	{
		if ((*p)->x == node.x && (*p)->y == node.y)
		{
			return (*p)->cost;
		}
	}
	for (auto p = closedList.begin(); p != closedList.end(); p++)
	{
		if ((*p)->x == node.x && (*p)->y == node.y)
		{
			return (*p)->cost;
		}
	}
}
// form the address into a single token
bool CThreadManager::mergeUSAddress(deque<CToken>& lsTokens, int& wc)
{
	bool bMerged=false;
	//step back until number or max of 20 tokens

	int max=20;
	CToken aToken;
	deque<CToken>::iterator ii;
	ii=lsTokens.end();
	ii--; //this is the zip code
	while (ii!=lsTokens.begin() && max-- > 0)
	{
		ii--;
		if (isNumber(ii->Token()))
		{
			//start concatenate from here
			int tokenCount=0;
			deque<CToken>::iterator starterase=ii;
			string aUSAddress;
			while (ii!=lsTokens.end())
			{
				aUSAddress += ii->Token();
				aUSAddress += " ";
				tokenCount++;
				ii++;
			}

			wc -= tokenCount;

			while (tokenCount-- > 0)
			{
				lsTokens.pop_back();
			}

			aToken.set(aUSAddress.c_str(),wc);
			lsTokens.push_back(aToken);
			
			break;
		}

	}

	bMerged=true;
	return bMerged;
}
Example #28
0
int main(void)
{
	int n,m,s,i,j,k,t,x;
	cin>>n>>m>>s;
	for(i=0;i<n;i++)
		cin>>w[i];
	for(i=0;i<m;i++)
	{
		cin>>j;
		cin>>t;
		child[j]=t;
		for(k=0;k<t;k++)
		{
			cin>>x;
			path[x]=j;
		}
	}
	for(i=0;i<n;i++)
	{
		if(child[i]!=0)
			continue;
		else
		{
			int sum=0;
			for(j=i;j!=0;j=path[j])
			{
				p[i].push_front(w[j]);
				sum+=w[j];
			}
			sum+=w[j];
			p[i].push_front(w[j]);
			if(sum==s)
				result.push_back(p[i]);
		}
	}
	sort(result.begin(),result.end(),greater<deque<int> >());
	for(it=result.begin();it!=result.end();it++)
	{
		cout<<(*it)[0];
		for(i=1;i<(*it).size();i++)
			cout<<" "<<(*it)[i];
		cout<<endl;
	}
	return 0;
}
Example #29
0
float Graph::getMedian(const deque<float>& buffer, float percentile) {
	if(buffer.empty()) {
		return 0;
	}
	vector<float> all;
	all.assign(buffer.begin(), buffer.end());
	ofSort(all);
	return all[(int) (all.size() * percentile)];
}
Example #30
0
 bool checkResult(int &ca,int &cb)          //¼ì²â´íÎó״̬ ÒÔÍ˳ö²»±ØÒªµÄµÝ¹é 
{
    if(ca==ica&&cb==icb)                   //¶¼Âú 
    {
      return false;
    }
   if(ca==0&&cb==0)                       //¶¼¿Õ 
    {
       return false;
    }
    
    if(find(travel.begin(),travel.end(),ca*10000+cb)!=travel.end())
    {
       return false;                                                                   
    }
   
    return true;  
}