Example #1
0
struct glyphtile *glyphatlas::getTile()
{
    struct glyphtile *t;

    if (free_.empty()) {
        assert(!used_.empty());

        t = used_.front();
        used_.pop_front();
        t->release();
    } else {
        t = free_.front();
        free_.pop_front();
    }

    used_.push_back(t);

    return t;
}
Example #2
0
int Componentes::adicionarVarios(list<string> its, int valor) {
    if (its.size() == 1) { 
        return this->adicionar(its.front(), valor);
    }
    else {
    	string s = its.front();
    	its.pop_front();
        return adicionar(s, adicionarVarios(its, valor));
    }
}
ScimBridgeMessage *ScimBridgeAgentClientListenerImpl::poll_message ()
{
    if (received_messages.size () > 0) {
        ScimBridgeMessage *message = received_messages.front ();
        received_messages.pop_front ();
        return message;
    } else {
        return NULL;
    }
}
Example #4
0
void login(list<int> int_params, list<string> string_params, sp_session *session, sp_track *track) {
	if (session == NULL)
		exitl("Logged in before session was initialized");
	string username = string_params.front();
	string_params.pop_front();
	string password = string_params.front();
	string_params.pop_front();
	string blob = string_params.front();
	log ("login %s",username.c_str());
	sp_error error;
	if (password.empty() && !blob.empty()){
	    error = sp_session_login(session, username.c_str(), NULL, true, blob.c_str());
	}
	else if (!password.empty() && blob.empty()){
        error = sp_session_login(session, username.c_str(), password.c_str(), true, NULL);
    }
    if (error != SP_ERROR_OK)
        log ("!!!login error occurred: %s",sp_error_message(error));
}
Example #5
0
void process()
{   setter(listsize,list1);
    setter(listsize,list2);
    int how_long=listsize;
    int toggle=0;
    show();
    for(int i=0; i<how_long; i++)
    {
        toggle=rand()%4;
        switch(toggle)
        {
        case 0:
        {
            list2.pop_front();
            list1.remove(seek_missing(list1,list2));
            show();
            break;
        }
        case 1:
        {
            list1.pop_back();
            list2.remove(seek_missing(list2,list1));
            show();
            break;
        }
        case 2:
        {
            list2.pop_back();
            list1.remove(seek_missing(list1,list2));
            show();
            break;
        }
        case 3:
        {
            list1.pop_front();
            list2.remove(seek_missing(list2,list1));
            show();
            break;
        }
        }
    }
    cout<<"All numbers erased."<<endl;
}
Example #6
0
BOOL Connect(PSOCKADDR_IN psain, PTCP_EP_HANDLER phandler, PTCP_OPTION popt, HPOOL hpool, LPVOID key)
{
	TCP_OPTION opt;
	SOCKADDR_IN sain;
	PCONNECTION pconn = NULL;

	if(!psain || !phandler || !hpool) return(FALSE);
	EnterCriticalSection(&cs_free_olist);
	if(!free_oconns.empty()) {
		pconn = (PCONNECTION)free_oconns.front();
		free_oconns.pop_front();
	}
	LeaveCriticalSection(&cs_free_olist);
	if(!pconn) {
		pconn = new CONNECTION;
		if(!pconn) return(FALSE);
		pconn->s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
		if(pconn->s==INVALID_SOCKET) {
			delete(pconn);
			return(FALSE);
		}
		if(popt) {
			ApplyTcpOption(pconn->s, popt);
		} else {
			GetDefTCPOpt(&opt);
			ApplyTcpOption(pconn->s, &opt);
		}
		pconn->hep = NULL;
		ZeroMemory(&sain, sizeof(sain));
		sain.sin_family = AF_INET;
		if(!BindIoCompletionCallback((HANDLE)pconn->s, SocketIOCompletionRoutine, 0) ||
			bind(pconn->s, (PSOCKADDR)&sain, sizeof(sain))==SOCKET_ERROR) {
				closesocket(pconn->s);
				delete(pconn);
				return(FALSE);
		}
		InterlockedIncrement((LONG *)&total_oconns);
	}
	pconn->pool = hpool;
	pconn->key = key;
	pconn->handler = *phandler;
	LPBYTE buf = LockInputBuffer(hpool);
	PAIO_CONTEXT pctx = CtxOfBuf(buf);
	pctx->operation = SIOP_CONNECT;
	pctx->hconn = (HCONNECT)pconn;
	if(!lpfnConnectEx(pconn->s, (PSOCKADDR)psain, sizeof(SOCKADDR_IN), NULL, 0, NULL, pctx) && WSAGetLastError()!=ERROR_IO_PENDING) {
		UnlockInputBuffer(buf);
		EnterCriticalSection(&cs_free_olist);
		free_oconns.push_front((HCONNECT)pconn);
		LeaveCriticalSection(&cs_free_olist);
		return(FALSE);
	}
	return(TRUE);
}
Example #7
0
 ogg_int64_t NextKeyframeTime() {
   while (mBuffer.size() > 0 && mBuffer.front().granulepos != -1) {
     PacketInfo p = mBuffer.front();
     mBuffer.pop_front();
     if (p.isKeyFrame) {
       assert(p.granulepos != -1);
       return Time(p.granulepos);
     }
   }
   return -1;
 }
Example #8
0
//devuelve la suma de los elementos de la lista
int getSuma(list<int> mi_lista)
{
    int pluss =0;

     while(!mi_lista.empty())//mira si esta vacia
    {
        pluss=pluss + mi_lista.front(); //suma la cola
        mi_lista.pop_front();
    }
    return pluss;//devuelve la suma
}
int play(int cover, list<char>& player, list<char>& played){
	if(!cover) cover=1;
	while(cover--){
		if(player.empty()) return -1;
		int face = mp(player.front());
		played.push_back(player.front());
		player.pop_front(); 
		if(face) return face;
	}
	return 0;
}
Example #10
0
void Player::destroyBattleParticipants(list <Personality*>& listA)
{
	Personality* soldier;
	list <Personality*>::iterator itP;

	while(listA.size() > 0){
        soldier = listA.front();
		listA.pop_front();
		RetireSoldier(soldier);
	}
}
Example #11
0
 vector<vector<int>> levelOrderBottom(TreeNode* root) {
     if(NULL == root)
         return vvec;
     vec.push_back(root->val);
     vvec.push_back(vec);
     vec.clear();
     if(root->left)
         lst1.push_back(root->left);
     if(root->right)
         lst1.push_back(root->right);
     while(!lst1.empty() || !lst2.empty()){
         while(!lst1.empty()){
             root = lst1.front();
             lst1.pop_front();
             vec.push_back(root->val);
             if(root->left)
                 lst2.push_back(root->left);
             if(root->right)
                 lst2.push_back(root->right);
         }
         if(!vec.empty()){
             vvec.push_back(vec);
             vec.clear();
         }
         while(!lst2.empty()){
             root = lst2.front();
             lst2.pop_front();
             vec.push_back(root->val);
             if(root->left)
                 lst1.push_back(root->left);
             if(root->right)
                 lst1.push_back(root->right);
         }
         if(!vec.empty()){
             vvec.push_back(vec);
             vec.clear();
         }
     }
     reverse(vvec.begin(),vvec.end());
     return vvec;
 }
int
DCLeaseManagerLease_freeList( list<DCLeaseManagerLease *> &lease_list )
{
	int		count = 0;
	while( lease_list.size() ) {
		DCLeaseManagerLease *lease = *(lease_list.begin( ));
		delete lease;
		lease_list.pop_front( );
		count++;
	}
	return count;
}
Example #13
0
bool go()
{
	while (true)
	{
		if (current_cell->x == goal_x && current_cell->y == goal_y)
		{
			Cell* parent_cell = current_cell->parent;
			while (parent_cell != NULL)
			{
				parent_cell->s = S_PATH;
				parent_cell = parent_cell->parent;
			}
			return true;
		}
		for (int i = 0; i < 8; i++)
		{
			int x = current_cell->x + step[i].x;
			int y = current_cell->y + step[i].y;
			if (x > -1 && x < width && y > -1 && y < height)
			{
				Cell* open_cell = &cell_map[y][x];
				if (open_cell->s == S_OPEN)
				{
					int g = current_cell->g + step[i].d;
					if (g < open_cell->g)
					{
						open_cell->g = g;
						open_cell->f = open_cell->g + open_cell->h;
						open_cell->parent = current_cell;
					}
				}
				else if (open_cell->s == S_EMPTY)
				{

					open_cell->g = current_cell->g + step[i].d;
					open_cell->f = open_cell->g + open_cell->h;
					open_cell->parent = current_cell;
					open_cell->s = S_OPEN;
					open_list.push_back(&cell_map[y][x]);
				}
			}
		}
		current_cell->s = S_CLOSE;
		close_list.push_back(current_cell);
		if (open_list.empty())
		{
			return false;
		}
		open_list.sort(CompareCell);
		current_cell = open_list.front();
		open_list.pop_front();
	}
}
Example #14
0
Void TEncRCPic::addToPictureLsit( list<TEncRCPic*>& listPreviousPictures )
{
	if ( listPreviousPictures.size() > g_RCMaxPicListSize )
	{
		TEncRCPic* p = listPreviousPictures.front();
		listPreviousPictures.pop_front();
		p->destroy();
		delete p;
	}

	listPreviousPictures.push_back( this );
}
Example #15
0
void Call::call( list<Param*> params, Block* block, list<Value*> args, SymbolTable t )
{
	if ( params.empty() && args.empty() )
		block->interpret( t );
	else
	{
		Param* par = params.front();
		Value* arg = args.front();
		params.pop_front();
		args.pop_front();
		
		if ( par->node_type == Node_ValParam )
		{
			ValParam* param = dynamic_cast<ValParam*>( par );
			
			if ( param->data_type == IntType )
				t.bind( param->ID, param->line, param->column, new IntCell( arg->getIntValue( arg->line, arg->column ), param->line, param->column ) );
			else
				t.bind( param->ID, param->line, param->column, new BoolCell( arg->getBoolValue( arg->line, arg->column ), param->line, param->column ) );
		}
		else
		{
			VarParam* param = dynamic_cast<VarParam*>( par );

			if ( param->data_type == IntType && arg->value_type == Value_IntCell )
				t.bind( param->ID, param->line, param->column, dynamic_cast<IntCell*>( arg ) );
			else if ( param->data_type == BoolType && arg->value_type == Value_BoolCell )
				t.bind( param->ID, param->line, param->column, dynamic_cast<BoolCell*>( arg ) );
			else
			{
				cout << "(!) Cannot pass " << nameOf( arg->value_type )
				<< " " << ID << " defined at " << arg->line << ":" << arg->column
				<< " to a parameter of type " << nameOf( param->data_type )
				<< " at " << param->line << ":" << param->column << endl;
				exit( 1 );
			}
		}
		call( params, block, args, t );
	}
}
Example #16
0
list<int> clean(list<int> cash)
{
	list<int> ret;
	map<int, int> check;
	while(!cash.empty()) {
		int give = cash.front();
		cash.pop_front();
		if (check[give]) continue;
		ret.push_back(give);
		check[give]++;
	}
	return ret;
}
Example #17
0
/*
 * Thread for issuing commands. 
 * Deques data from the receive queue and issues the commands with servoblaster
 */
void cmdIssuer() {
  while(1) {
    bool validData = false;
    queueMutex.lock();
    if(!cmdQueue.empty()) {
      char *data = (char *)cmdQueue.front();
      cmdQueue.pop_front();
      cout << "received message: " << data << endl;
      validData = true;
    }
    queueMutex.unlock();
  }
}
Example #18
0
int main() {
   string palabra = "ABCD";
   int tam = 0;
   Permutaciones(palabra);
   tam =  palabras.size();
   for (int i = 0; i < tam; ++i)
   {
      cout << palabras.front() << endl;
      palabras.pop_front();
   }
   cin.get();
   return 0;
}
Example #19
0
//Devuelve true si los elementos de la lista son palindromos, de lo contrario devuelve false
bool esPalindroma(list<char>mi_lista)
{
      while(!mi_lista.empty())//mira si esta vacia
    {
        if (mi_lista.front()== mi_lista.back()) //si son iguales decuelve verdadero de lo contrario falso
    {
        return true;
    }
    mi_lista.pop_front();
    mi_lista.pop_back();
    }
    return false;
}
  inline request_data::pointer get() {
    std::unique_lock<std::mutex> lock(mutex);

    request_data::pointer request;
    if (!requests.empty()) {
      request = requests.front();
      requests.pop_front();
    }

    (void)lock;

    return request;
  }
Example #21
0
VOID ASockIOFini()
{
	while(free_oconns.size()!=total_oconns) Sleep(0);
	PCONNECTION pconn;
	while(!free_oconns.empty()) {
		pconn = (PCONNECTION)free_oconns.front();
		free_oconns.pop_front();
		closesocket(pconn->s);
		delete(pconn);
	}
	WSACleanup();
	DeleteCriticalSection(&cs_free_olist);
}
Example #22
0
void update_giovanni(vector<list<int>> &adj, list<int> neighborhood, vector<int> &degs, int dancer, int degree)
{
    if(degree < degs[dancer])
    {
        degs[dancer] = degree;
        while(!neighborhood.empty())
        {
            int partner = neighborhood.front();
            update_giovanni(adj, adj[partner], degs, partner, degree+1);
            neighborhood.pop_front();
        }
    }
}
Example #23
0
/// Sorts and filters a list of integers.
///
/// @param listVals
///     List of integers to sort and filter.
/// @param bRemoveZeros
///     Remove zeros from the list.
/* static */ void s_SortAndFilter(list<int>& listVals, bool bRemoveZeros)
{
    listVals.sort();
    listVals.unique();
    if (bRemoveZeros)
    {
        while (!listVals.empty() &&
               listVals.front() == 0)
        {
            listVals.pop_front();
        }
    }
}
list<int> arrObj::merge(list<int> a, list<int> b)
{
  list<int> result;
  while ((a.size() > 0) || (b.size() > 0)) {
    if ((a.size() > 0) && (b.size() > 0)) {
      if (a.front() <= b.front()) {
        result.push_back(a.front());
        a.pop_front();
      } else {
        result.push_back(b.front());
        b.pop_front();
      }
    } else if (a.size() > 0) {
      result.push_back(a.front());
      a.pop_front();
    } else if (b.size() > 0) {
      result.push_back(b.front());
      b.pop_front();
    }
  }
  return result;
}
void assignmentManager::sortlist(list<assignment> assignList) {

	list<assignment>::iterator itr;
	list<assignment>::iterator itr2;
	itr = assignList.begin();
	itr2 = assignList.end();
	int index = 0;
	int length = assignList.size();
	while (index < length) {
		cout << itr->date1.toString();
		cout << itr2->date1.toString();
		Date dateA = itr->date1;
		Date dateB = itr2->date1;
		if (dateA > dateB)
	{
			assignList.push_back(*itr);
			assignList.pop_front();
			itr = assignList.begin();
			itr2++;
		}
		else if (dateA < dateB) {
			bool loop = true;
			while (loop) {
				itr2--;
				if (dateA > dateB)
				{
					assignList.insert(itr2++, *itr);
					assignList.pop_front();
					itr = assignList.begin();
					itr2++;
					loop = false;
				}
			}
		}
		index++;


	}
}
Example #26
0
void InputHandler::update(float frameDelta) {
	while(keylist.size() > 8) {
		keylist.pop_front();	
	}

	if(controlNode != NULL) {
		controlNode->receiveKeyEvent(keylist);
	} else {
		for(list<SceneNode*>::iterator x = receivers->begin(); x != receivers->end(); x++)
			(*x)->receiveKeyEvent(keylist);
	}
	keylist.clear();
}
Example #27
0
void
HandleJob (list < Process > &JobQ, list < Process > &RQ1,
	   vector < string > &tokens, int &time, bool & ev, bool & eve,
	   bool & getcm, int &memory, int &count, int &tot_proc)
{
  if (tokens[0] == "A") {
    if (count == 0) {
      time = StringToInt (tokens[1]);
      count++;
    }
    if (time == StringToInt (tokens[1])) {
      Process newp;
      newp.Event = "A";
      newp.RQ = "RQ1";
      newp.Time = StringToInt (tokens[1]);
      newp.Job = StringToInt (tokens[2]);
      newp.Memory = StringToInt (tokens[3]);
      newp.RT = StringToInt (tokens[4]);
      newp.RTM = StringToInt (tokens[4]);
      newp.started = false;
      newp.IOBurst = 0;
      newp.IOClean = false;
      newp.RQT = 0;
      ev = true;
      if (newp.Memory <= 512) {
	JobQ.push_back (newp);
	tot_proc++;
      }
      else {
	eve = true;
      }
      getcm = true;
    }
    else {
      getcm = false;
    }
  }
  while (!JobQ.empty ()) {
    if (JobQ.front ().Memory <= memory) {
      JobQ.front ().RQT = time;
      RQ1.push_back (JobQ.front ());
      memory -= JobQ.front ().Memory;
      JobQ.pop_front ();
    }
    else {
      break;
    }
  }


}
Example #28
0
static void do_scc_dfs(const SGraph *graph,
                       SGraphNode src,
                       suif_vector<int> &node_id,
                       suif_vector<int> &dfsnum,
                       int &starttime,
                       list<int> &SC,
                       BitVector &touched,
                       suif_vector<int> &low,
                       list<int> &dfslist) {

    dfslist.push_back(src);
    //int srcid = node_id[src]; // get an id number
    starttime++;
    int dfsid = starttime;
    dfsnum[src] = dfsid;
    low[src] = dfsid;

//#  print "Dfs->$src $dfsid\n";
    touched.set_bit(src, 0);

    for (SNodeIter iter(graph->get_node_successor_iterator(src));
            !iter.done(); iter.increment()) {
        SGraphNode dst = iter.get();

        //int dstid = node_id[dst];
        if (dfsnum[dst] == 0) {
            do_scc_dfs(graph, dst, node_id, dfsnum,
                       starttime, SC, touched, low, dfslist);

            if (low[dst] < low[src]) {
                low[src] = low[dst];
            }
        } else {
            if (! touched.get_bit(dst) ) {
                if (dfsnum[dst] < low[src]) {
                    low[src] = dfsnum[dst];
                }
            }
        }
    }
    if (low[src] == dfsnum[src]) {
        touched.set_bit(src, true);
        while (SC.length() != 0 &&
                dfsnum[SC.front()] > dfsnum[src]) {
            touched.set_bit(SC.front(), true);
            SC.pop_front();
        }
    } else {
        SC.push_front(src);
    }
}
Example #29
0
Cell* ProcedureCell::  apply(Cell*args)
{     
      map<string,Cell*> local_table;
      if(this->get_formals()!=nil)
      {
         Cell* formal_count=this->get_formals();
         Cell* argument_count=args;
         if(!listp(args)) 
         {throw runtime_error("Must receice a list of arguments");}
         if(operand_num(this->get_formals())!=operand_num(args))
         {throw runtime_error("Wrong number of arguments");}
         else{
            //cout<<"1"<<endl;
            while (formal_count!=nil)
            {
               local_table[formal_count->get_car()->get_symbol()]=eval(argument_count->get_car());
               formal_count=formal_count->get_cdr();
               argument_count=argument_count->get_cdr();
            }
            map_list.push_front(local_table);//the new table is push in the front
         }
      }
      Cell* eval_count=this->get_body();//cout<<"2 "<<*eval_count<<endl;
      Cell* result;
      try{
      while (eval_count->get_cdr()!=nil)
      {  //cout<<"3"<<endl;
         eval(eval_count->get_car());//cout<<"4"<<endl;
         eval_count=eval_count->get_cdr();
         
      }
      result=eval(eval_count->get_car());
      }
      catch(runtime_error & e)
      {map_list.pop_front();throw e;}
      if(this->get_formals()!=nil) map_list.pop_front();
      return result;
} 
Example #30
0
    T get_one()
    {
        std::lock_guard<std::mutex> lock(_mtx);

        if(_datas.size() == 0)
        {
            return T();
        }

        T one = _datas.front();
        _datas.pop_front();

        return one;
    }