当前位置: 首页>>代码示例>>C++>>正文


C++ queue::front方法代码示例

本文整理汇总了C++中std::queue::front方法的典型用法代码示例。如果您正苦于以下问题:C++ queue::front方法的具体用法?C++ queue::front怎么用?C++ queue::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::queue的用法示例。


在下文中一共展示了queue::front方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: consumer

void consumer(int num){
	//pop valus if available (num identifies the consumer)
	while(true){
		int val;
		{
			std::unique_lock<std::mutex> ul(queueMutex);
			queueConVar.wait(ul, []{return !queue.empty();});
			val = queue.front();
			queue.pop();
		}//release lock
		printf("consumer %d : %d,\n", num, val);
	}
}
开发者ID:catchSora,项目名称:exercises,代码行数:13,代码来源:condiVarQueue.cpp

示例2: print

void print(std::queue<vec> s)
{
  int sizeQueue=s.size();
  //DispVal(sizeQueue);
 
    while(sizeQueue!=0){
      vec x= s.front();
      s.pop();
      std::cout << x << "\n";
      sizeQueue--;
    }
    return;
}
开发者ID:tony2909,项目名称:green,代码行数:13,代码来源:rx_funct.cpp

示例3: receive

    virtual uavcan::int16_t receive(uavcan::CanFrame& out_frame, uavcan::MonotonicTime& out_ts_monotonic,
                                    uavcan::UtcTime& out_ts_utc, uavcan::CanIOFlags& out_flags)
    {
        assert(this);
        if (loopback.empty())
        {
            EXPECT_TRUE(rx.size());        // Shall never be called when not readable
            if (rx_failure)
            {
                return -1;
            }
            if (rx.empty())
            {
                return 0;
            }
            const FrameWithTime frame = rx.front();
            rx.pop();
            out_frame = frame.frame;
            out_ts_monotonic = frame.time;
            out_ts_utc = frame.time_utc;
            out_flags = frame.flags;
        }
        else
        {
            out_flags |= uavcan::CanIOFlagLoopback;
            const FrameWithTime frame = loopback.front();
            loopback.pop();
            out_frame = frame.frame;
            out_ts_monotonic = frame.time;
            out_ts_utc = frame.time_utc;
        }

        // Let's just all pretend that this code is autogenerated, instead of being carefully designed by a human.
        if (out_ts_utc.isZero())
        {
            out_ts_utc = enable_utc_timestamping ? iclock.getUtc() : uavcan::UtcTime();
        }
        return 1;
    }
开发者ID:BillTian,项目名称:uavcan,代码行数:39,代码来源:can.hpp

示例4: pop

				int pop(T *out)
				{
					std::unique_lock<std::mutex> lock(m_mutex);				
				    while (isEmpty()) m_condNotFull.wait(lock);
					
					m_rwmut.lock();
						*out = m_que.front();
						m_que.pop();
					m_rwmut.unlock();
					
					m_condNotEmpty.notify_all();					
					return 0;
				}
开发者ID:SmartActiveNode2,项目名称:san2,代码行数:13,代码来源:cproducerconsumer.hpp

示例5: getVictim

int getVictim(frame_t *victim){
	switch(CUR_ALGO){
		case FIFO:
			*victim = fifo_queue.front();//get victim
			fifo_queue.pop();//move queue forward
			break;
		case LRU:
			*victim = lru_queue.front();//get victim
			lru_queue.pop();//move queue forward
			break;
		case CLOCK:
			clockVictim(victim);
			break;
		case ECLOCK:
			clockVictim(victim);
			break;
		default:
			return -1; //invalid, use default
			break;
	}
	return 0;
}
开发者ID:grpatter,项目名称:iu_cs_jegm,代码行数:22,代码来源:pagealgorithms.c

示例6: RunFullDiscovery

void MockRDMController::RunFullDiscovery(RDMDiscoveryCallback *callback) {
  CPPUNIT_ASSERT(m_expected_discover_calls.size());
  expected_discovery_call call = m_expected_discover_calls.front();
  m_expected_discover_calls.pop();
  CPPUNIT_ASSERT(call.full);

  if (call.uids) {
    callback->Run(*call.uids);
  } else {
    CPPUNIT_ASSERT(!m_discovery_callback);
    m_discovery_callback = callback;
  }
}
开发者ID:Siliconsoul,项目名称:ola,代码行数:13,代码来源:QueueingRDMControllerTest.cpp

示例7: RunFullDiscovery

void MockRDMController::RunFullDiscovery(RDMDiscoveryCallback *callback) {
  OLA_ASSERT_TRUE(m_expected_discover_calls.size());
  expected_discovery_call call = m_expected_discover_calls.front();
  m_expected_discover_calls.pop();
  OLA_ASSERT_TRUE(call.full);

  if (call.uids) {
    callback->Run(*call.uids);
  } else {
    OLA_ASSERT_FALSE(m_discovery_callback);
    m_discovery_callback = callback;
  }
}
开发者ID:nightrune,项目名称:ola,代码行数:13,代码来源:QueueingRDMControllerTest.cpp

示例8: pop

	bool pop(T &item)
	{
		item = NULL;

		std::unique_lock<std::mutex> lock(mutex_);

		if (queue_.empty()) return false;

		item = queue_.front();
		queue_.pop();

		return true;
	}
开发者ID:dspshin,项目名称:ff-player,代码行数:13,代码来源:ThreadQueue.hpp

示例9: Dequeue

    // Get data from the queue. Wait for data if not available
  T Dequeue(){
    // Acquire lock on the queue
    boost::unique_lock<boost::mutex> lock(m_mutex);

    // When there is no data, wait till someone fills it.
    // Lock is automatically released in the wait and obtained
    // again after the wait
    while (m_queue.size()==0) m_cond.wait(lock);

    // Retrieve the data from the queue
    T result=m_queue.front(); m_queue.pop();
    return result;
  } // Lock is automatically released here
开发者ID:mincongzhang,项目名称:PlayWithMultithreading,代码行数:14,代码来源:ProducerComsumer_SynchronisedQueue.cpp

示例10: reclaimObject

	/**
		回收一个对象容器
	*/
	void reclaimObject(std::queue<T*>& objs)
	{
		mutex_.lockMutex();
		
		while(!objs.empty())
		{
			T* t = objs.front();
			objs.pop();
			reclaimObject_(t);
		}

		mutex_.unlockMutex();
	}
开发者ID:321543223,项目名称:kbengine,代码行数:16,代码来源:objectpool.hpp

示例11: main

int main(void)
{
	scanf("%d", &spies);
	for(int s = 0; s < spies; ++ s)
	{
		scanf("%d", &spy);
		-- spy;
		++ followed[spy];
		following[s] = spy;
	}

	for(int s = 0; s < spies; ++ s)
		if(!followed[s])
			que.push(s);

	while(!que.empty())
	{
		spy = que.front();
		que.pop();

		if(following[spy] == -1)
			continue;

		if(following[following[spy]] == -1)
			continue;

		++ result;
		if(!-- followed[following[following[spy]]])
			que.push(following[following[spy]]);

		following[following[spy]] = -1;
		following[spy] = -1;
	}

	for(int s = spy = 0, count, o; s < spies; spy = ++ s)
	{
		count = 0;
		while(following[spy] != -1)
		{
			++ count;
			o = spy;
			spy = following[spy];
			following[o] = -1;
		}

		result += count / 2;
	}

	printf("%d\n", result);
	return 0;
}
开发者ID:Neverous,项目名称:individual,代码行数:51,代码来源:szp.cpp

示例12: OnTimer

void CConfigDialog::OnTimer(UINT nIDEvent) 
{
	if (nIDEvent==1001)
	{
		KillTimer(1001);
		CMemReaderProxy reader;
		switch (reader.getConnectionState())
		{
		case 0: 
				if (loginTime){
					char buf[128];
					if (loginTime-time(NULL)>=0) sprintf(buf,"Connection status: waiting to log in %d seconds.",loginTime-time(NULL));
					else sprintf(buf,"Connection status: trying to log in for %d seconds.",time(NULL)-loginTime);
					m_status.SetWindowText(buf);break;
				}
				m_status.SetWindowText("Connection status: not connected");break;
		case 1: m_status.SetWindowText("Connection status: opening to login server");break;
		case 2: m_status.SetWindowText("Connection status: connecting to login server");break;
		case 3: m_status.SetWindowText("Connection status: disconnecting from login server");break;
		case 4: m_status.SetWindowText("Connection status: connected to login server");break;
		case 5: m_status.SetWindowText("Connection status: opening");break;
		case 6: m_status.SetWindowText("Connection status: connecting");break;
		case 7: m_status.SetWindowText("Connection status: disconnecting");break;
		case 8: m_status.SetWindowText("Connection status: connected");break;
		default: m_status.SetWindowText("Connection status: unknown");break;
		};

		EnterCriticalSection(&QueueCriticalSection);
		while (!queue2.empty())
		{
			char timeBuf[256];
			char *msg = queue2.front();
			queue2.pop();
			m_debug.InsertItem(0,"");
			time_t nowSec = time(NULL);
			struct tm *now = localtime(&nowSec);
			sprintf(timeBuf,"%d:%d:%d",now->tm_hour,now->tm_min,now->tm_sec);
			m_debug.SetItemText(0,0,timeBuf);
			m_debug.SetItemText(0,1,msg);			
			if (m_debug.GetItemCount()>100)
			{
				m_debug.DeleteItem(m_debug.GetItemCount());
			}
			delete msg;
		}
		LeaveCriticalSection(&QueueCriticalSection);
		SetTimer(1001,500,NULL);
	}
	
	CDialog::OnTimer(nIDEvent);
}
开发者ID:zekoman,项目名称:tibiaauto,代码行数:51,代码来源:ConfigDialog.cpp

示例13: flip

int flip()
{
	int loop_count = 0;

	while(!stat_queue.empty())
	{
		loop_count++;
		unsigned long stat = stat_queue.front();
		stat_queue.pop();
		if(finished(stat))
		{
			int steps = 0;
			while(path[stat] != 0)
			{
				++steps;
				stat = path[stat];
			}
			printf("%d", steps);
			return 0;
		}
		int xPos, yPos;
		for(xPos = 0; xPos < N; ++xPos)
		{
			for(yPos = 0; yPos < N; ++yPos)
			{
				int i;
				std::bitset < 16 > next_stat(stat);
				for(i = 0; i < 5; ++i)
				{
					if(is_legal_position(xPos + move[i][0], yPos + move[i][1]) )
					{
						next_stat.flip((xPos + move[i][0]) * N + (yPos + move[i][1]) );
					}

				}

				//printf("%d\n", next_stat.to_ulong());
				unsigned long num_status = next_stat.to_ulong();
				if(!status_set.test(num_status))
				{
					status_set.set(num_status);
					//remember where current status comes from.
					path[num_status] = stat;
					stat_queue.push(num_status);
				}
			}
		}
	}
	printf("Impossible");
	return -1;
}
开发者ID:jflyup,项目名称:POJ,代码行数:51,代码来源:poj1753.cpp

示例14: spiReceive

  //------------------------------------------------------------------------------------------------------------------------------------
  bool __stdcall spiReceive(SOCKADDR **senderPeer, char **data, DWORD *databytes)
  {
    INTERLOCKED;
//    DropMessage(0, "spiReceive %d", GetCurrentThreadId());
    // Passes pointers from queued receive data to storm

    *senderPeer = nullptr;
    *data       = nullptr;
    *databytes  = 0;

    try
    {
      pluggedNetwork->receive();

      while(true)
      {
        // check if packets available
        if(incomingGamePackets.empty())
        {
          SErrSetLastError(STORM_ERROR_NO_MESSAGES_WAITING);
          return false;
        }

        // save the packet before removing it from queue
        GamePacket *loan = new GamePacket();
        *loan = incomingGamePackets.front();
        incomingGamePackets.pop();

        // paket outdated?
        if(GetTickCount() > loan->timeStamp + 10000)
        {
          DropMessage(1, "Dropped outdated packet (%dms delay)", GetTickCount() - loan->timeStamp);
          continue;
        }

        // give saved data to storm
        *senderPeer =&loan->sender;
        *data       = loan->data;
        *databytes  = loan->packetSize;
//        DropMessage(0, "R %s", sprintfBytes(*data, *databytes));
//        DropMessage(0, "Received storm packet %d bytes", *databytes);
        break;
      }
    }
    catch(GeneralException &e)
    {
      DropLastError("spiLockGameList failed: %s", e.getMessage());
      return false;
    }
    return true;
  }
开发者ID:AdamKotynia,项目名称:bwapi,代码行数:52,代码来源:SNPModule.cpp

示例15: PortException

void
GraphTools::__BFS( std::queue< raft::kernel* > &queue,
                   std::set< raft::kernel*   > &visited_set,
                   vertex_func                 func,
                   void                        *data )
{
#if 0
   while( queue.size() > 0 )
   {
      auto *source( queue.front() );
      queue.pop();
      /** iterate over all out-edges **/
      /** 1) get lock **/
      std::lock_guard< std::mutex > lock( source->output.portmap.map_mutex );
      /** 2) get map **/
      std::map< std::string, PortInfo > &map_of_ports( source->output.portmap.map );
      /** 3) visit kernel **/
      func( *source, data );
      /** 4) add children to queue **/
      for( auto &port : map_of_ports )
      {
         PortInfo &source( port.second );
         /** get dst edge to call function on **/
         if( source.other_kernel != nullptr  )
         {
            PortInfo &dst( 
               source.other_kernel->input.getPortInfoFor( source.other_name ) );
            func( source, dst, data );
         }
         else
         if( connected_error )
         {
            std::stringstream ss;
            ss << "Unconnected port detected at " << 
               common::printClassName( *k ) <<  
                  "[ \"" <<
                  source.my_name << " \"], please fix and recompile.";
            throw PortException( ss.str() );
         }
         /** if the dst kernel hasn't been visited, visit it **/
         if( visited_set.find( source.other_kernel ) == visited_set.end() )
         {
            queue.push( source.other_kernel );
            visited_set.insert( source.other_kernel ); 
         }
      }
   }
   return;
#endif
   assert( false ); /** FIXME: error above with virtual function 'func', fix in a bit **/
}
开发者ID:tempbottle,项目名称:RaftLib,代码行数:51,代码来源:graphtools.cpp


注:本文中的std::queue::front方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。