Example #1
0
Node* SearchGraph::bfsRemove() {
  if(!fringe.empty()) {
    Node* n = fringe.front();
    fringe.pop_front(); 
    return n;
  }
  else
    return NULL;
}
Example #2
0
void print(const list<T> &integersRef) {
    if (integersRef.empty()) // list is empty
        cout << "List is empty";
    else {
        ostream_iterator<T> output(cout, " ");
        copy(integersRef.begin(), integersRef.end(), output);

    }
}
Example #3
0
// Index a list of files. We just call the top indexer method, which
// will sort out what belongs to the indexed trees and call the
// appropriate indexers.
//
// This is called either from the command line or from the monitor. In
// this case we're called repeatedly in the same process, and the
// confindexer is only created once by makeIndexerOrExit (but the db closed and
// flushed every time)
bool indexfiles(RclConfig *config, list<string> &filenames)
{
    if (filenames.empty())
	return true;
    makeIndexerOrExit(config, (op_flags & OPT_Z) != 0);
    return confindexer->indexFiles(filenames, (op_flags&OPT_f) ? 
				   ConfIndexer::IxFIgnoreSkip : 
				   ConfIndexer::IxFNone);
}
Example #4
0
 Dog dequeueDog(){
   if (!dogs.empty()){
     Dog ani = dogs.front();
     dogs.pop_front();
     return ani;
   }else{
    cerr<< "Empty dogs" << endl;
   }
 };
Example #5
0
File: files.C Project: HeyJJ/ball
void SingleFile::moveBack()
{
	while (!composites.empty())
	{
		// insert all composites back into the system
		system.prependChild(*composites.back());
		composites.pop_back();
	}
}
Example #6
0
Message *HistoryFileIterator::operator ++()
{
    if (m_msg)
    {
        delete m_msg;
        m_msg = NULL;
    }
    while (msgs.empty())
        if (loadBlock(true))
            break;
    if (!msgs.empty())
    {
        m_msg = msgs.front();
        msgs.pop_front();
        return m_msg;
    }
    return NULL;
}
Example #7
0
 Cat dequeueCat(){
    if (!cats.empty()){
      Cat ani = cats.front();
      cats.pop_front();
      return ani;
    }else{
     cerr<< "Empty cats" << endl;
    }
  }
Example #8
0
int			TriFanBuilder::GetNextPrimitive(list<CDT::Vertex_handle>& out_handles)
{
	out_handles.clear();
	GetNextTriFan(out_handles);
	if(!out_handles.empty())	return dsf_TriFan;

	GetRemainingTriangles(out_handles);
								return dsf_Tri;
}
Example #9
0
void t_hdr_supported::add_features(const list<string> &l) {
	if (l.empty()) return;
	
	for (list<string>::const_iterator i = l.begin(); i != l.end(); i++)
	{
		add_feature(*i);
	}
	populated = true;
}
Example #10
0
File: 2d.cpp Project: pikle6/OpenGL
void key(unsigned char key_t, int x, int y){
    if(key_t=='d' && reset == 1){
        enter = 0;
        reset = 0;
        drawPolygon();
        redraw();
        in.empty();
    }
    if(key_t=='r'){
        reset = 1;
        glClear(GL_COLOR_BUFFER_BIT);
        glFlush();
        rgb_set();
        enter = 1;
        //reset transform vars
        trans = 0;
        transtrack = 0;
        sc = 0;
        strack = 0;
		rot = 0;
		rotrack = 0;
		pencil = 0;
    }
    if(key_t=='q'){
        redraw();
    }
    if(key_t=='t'){
        trans=1;
    }
    if(key_t=='s'){
        sc=1;
    }
    if(key_t=='p'){
        pencil=1;
    }
    if(key_t=='x'){
        rot=1;
        grxmin = gxmin;
        grymin = gymin;
    }

    if(key_t<=57 && key_t>=48){
        int val = key_t - 48;
        switch(val){
            case 0: rgb(26.0, 188.0, 156.0);break;
            case 1: rgb(46.0, 204.0, 113.0);break;
            case 2: rgb(52.0, 152.0, 219.0);break;
            case 3: rgb(155.0, 89.0, 182.0);break;
            case 4: rgb(52.0, 73.0, 94.0);break;
            case 5: rgb(241.0, 196.0, 15.0);break;
            case 6: rgb(230.0, 126.0, 34.0);break;
            case 7: rgb(231.0, 76.0, 60.0);break;
            case 8: rgb(236.0, 240.0, 241.0);break;
            case 9: rgb(149.0, 165.0, 166.0);break;
        }
    }
}
Example #11
0
void KeypressEventsHandler::InitModifiers()
{
  if (modifiers_.empty() == false) {
    modifiers_.clear();
  }

  modifiers_.push_back(XModifierKey(GDK_Shift_L, GDK_SHIFT_MASK));
  modifiers_.push_back(XModifierKey(GDK_Control_L, GDK_CONTROL_MASK));
  modifiers_.push_back(XModifierKey(GDK_Alt_L, GDK_MOD1_MASK));
}
Example #12
0
File: main.cpp Project: CCJY/coliru
void Person::unFriend()
{
    mt19937 seed;
    if (!following.empty()) {
        uniform_int_distribution<> dis(0, following.size() - 1);
        auto unfriend = following.begin();
        for(int pos = dis(seed); pos > 0; --pos, ++unfriend);
        following.erase(unfriend);
    }        
}
Example #13
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 #14
0
void graph::printLongestPath(list<unsigned int> path, int max_dist)
{
    cout<< "A longest path is found of size "<< max_dist << ": " << endl;
    while(!path.empty())
    {
        cout<< path.back() << ";";
        path.pop_back();
    }
    cout<< endl;
}
Example #15
0
QueueElement QueueWithPriority::GetElementFromQueue() {
    if ( qwp_list.empty() )
        throw std::runtime_error("QueueIsEmptyExeption");
//  Если список пустой то выбросим прерывание
    QueueElement qe;
    list<QueueElement>::iterator it;
    qe = *qwp_list.end();
    qwp_list.pop_back();
    return qe;
}
Example #16
0
void *MessageHandler(void *) {
	while (1) {
		while (!MessageQueue.empty()) {
			cout << "Received order: " << MessageQueue.front() << endl;
			MessageQueue.pop_front();
		}

	}
	return 0;
}
int main()
{
	int e;
	while(scanf("%d", &e), e!= -1)
	{
		A.push_back(e);
	}
	while(scanf("%d", &e), e!= -1)
	{
		B.push_back(e);
	}
	while(!A.empty() && !B.empty())
	{
		if(A.front() < B.front())
		{
			A.pop_front();
		}
		else if(A.front() > B.front())
		{
			B.pop_front();
		}
		else
		{
			C.push_back(A.front());
			A.pop_front();
			B.pop_front();
		}
	}
	if(C.empty())	cout << "NULL" << endl;
	else
	{
		cout << C.front();
		C.pop_front();
		while(!C.empty())
		{
			cout << " " << C.front();
			C.pop_front();
		}
		cout << endl;
	}
	return 0;
}
Example #18
0
list<string> UserSearchTopic::getAllSortingCriteria() {
	static list<string> result;
	if (result.empty()) {
		result.push_back("session count");
		result.push_back("total query count");
		result.push_back("unique query count");
		result.push_back("total click count");
		result.push_back("unique click count");
	}
	return result;
}
Example #19
0
void API_Delete(Table tbl, list<Condition> &clist)
{
	int flag = 0;
	if (clist.empty())flag = 1;
	list<Condition> Have_Index_Condition;
	list<Condition> No_Index_Condition;
	list<Condition>::iterator it;
	string IndexNameList[100];
	int Attribute_Size[100];
	int i=0;
	for(it=clist.begin();it!=clist.end();it++){
		Attribute_Size[i] = tbl.getAttr(it->compare_attr).attr_len;
		IndexNameList[i++] = tbl.getAttrIndex(it->compare_attr);
		if(!IndexNameList[i-1].empty()&&it->compare_type!=NOT_EQUAL){
			Have_Index_Condition.push_back(*it);
		}
		else{
			i--;
			No_Index_Condition.push_back(*it);
		}
	}
	i=0;
	vector<int> finalOfstList;
	vector<int> tempOfstList;
	vector<int>::iterator endOfList;
	for(it=Have_Index_Condition.begin();it!=Have_Index_Condition.end();it++){
		if (it == Have_Index_Condition.begin()){
			Index_Select_Position(*it, IndexNameList[i], finalOfstList, Attribute_Size[i], tbl.getAttr((*it).compare_attr).attr_type);
			i++;
		}
		else{
			Index_Select_Position(*it,IndexNameList[i],tempOfstList,Attribute_Size[i],tbl.getAttr((*it).compare_attr).attr_type);
			i++;
			sort(finalOfstList.begin(), finalOfstList.end());
			sort(tempOfstList.begin(), tempOfstList.end());
			endOfList = set_intersection(finalOfstList.begin(), finalOfstList.end(), tempOfstList.begin(), tempOfstList.end(), finalOfstList.begin());
			finalOfstList.resize(endOfList - finalOfstList.begin());
			sort(finalOfstList.begin(), finalOfstList.end());
			finalOfstList.erase(unique(finalOfstList.begin(), finalOfstList.end()), finalOfstList.end());
		}
		if(finalOfstList.empty()){
			cout << "Query OK, 0 rows affected." << endl;
			return;
		}
	}
	Tuple selectTuple(tbl.getTableName());

	if (flag)finalOfstList.push_back(0);//clist为空
	else if (Have_Index_Condition.empty())finalOfstList.push_back(1);//clist不为空,且无索引信息
	else if (finalOfstList.empty())finalOfstList.push_back(2);//正常,但是索引找到的list为空
	else finalOfstList.push_back(3);//正常
	int deleteNum=selectTuple.Delete(finalOfstList, No_Index_Condition);
	cout << "Query OK, "<< deleteNum <<" rows affected." << endl;
}
Example #20
0
int CProjConfig::GetSectionList(list<string>& SectionList)
{
    SectionList.empty();
	for (SECTIONMAP::iterator i = m_MapOfSection.begin();
         i != m_MapOfSection.end(); i++)
	{
        SectionList.push_front(i->first);
	}

    return GetSectionCount();
}
Example #21
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 #22
0
void NavSum::printCurrentFilter()
{
   cout << "Current filtering options:" << endl
        << "\tStart time:\t" << startTime << endl
        << "\tEnd time:\t" << endTime << endl
        << "\tPRNs:\t\t";
   if (prnFilterList.empty())
      cout << "using all PRNs";
   else
      copy(prnFilterList.begin(), prnFilterList.end(),
           ostream_iterator<long>(cout, " "));
   cout << endl
        << "\tFIC blocks:\t";
   if (blockFilterList.empty())
      cout << "using all blocks";
   else
      copy(blockFilterList.begin(), blockFilterList.end(),
           ostream_iterator<long>(cout, " "));
   cout << endl;
}
Example #23
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
}
Example #24
0
void rmInferiorNodes(list<Node> &q, const map<vector<int>, int> &score_table) {
	assert(!q.empty());
	for (list<Node>::iterator i = begin(q); i != end(q);) {
		if (score_table.find(i->getDepts()) != end(score_table)
				&& i->getScore() < score_table.at(i->getDepts())) {
			i = q.erase(i);
			continue;
		}
		++i;
	}
}
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;
}
// 初始化参数
bool GetUsersInfoTask::InitParam(const list<string>& userIdList)
{
	bool result = false;
	if (!userIdList.empty()) {
		m_userIdList = userIdList;

		result = true;
	}

	return result;
}
Example #27
0
string connectCmd(const list<string> &args)
{
	if ( !args.empty() )
	{
#ifndef DISABLE_ZOIDCOM
		network.connect( *args.begin() );
#endif
		return "";
	}
	return "CONNECT <HOST_ADDRESS> : JOIN A NETWORK SERVER";
}
Example #28
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;
 }
Example #29
0
string execCmd(const list<string> &args)
{
	if (!args.empty())
	{
		if ( console.executeConfig(*args.begin()) )
		{
			return "DONE";
		}
		return ( "COULDN'T EXEC " + *args.begin() );
	}
	return "EXEC <FILENAME> : EXECUTE A SCRIPT FILE";
}
Example #30
0
string gameCmd(const list<string> &args)
{
	if (!args.empty())
	{
		string tmp = *args.begin();
		std::transform(tmp.begin(), tmp.end(), tmp.begin(), (int(*)(int)) tolower);
		if(!game.setMod( tmp ))
			return "MOD " + tmp + " NOT FOUND";
		return "THE GAME WILL CHANGE THE NEXT TIME YOU CHANGE MAP";
	}
	return "GAME <MODNAME> : SET THE MOD TO LOAD THE NEXT MAP CHANGE";
}