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


C++ std::queue类代码示例

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


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

示例1:

 typename std::queue<T>::size_type
 unsafe_size() {
     return q_.size();
 }
开发者ID:straszheim,项目名称:mephitis,代码行数:4,代码来源:concurrent_queue.hpp

示例2: updateAudioEffects

	void AudioManager::updateAudioEffects() {
		static std::queue<int> nextNumbers; // indexes used!
		if (m_bIsPlayingNumber == true) {           // number update
			if (isAnyNumberPlayed() == false) {     // one sound finished
				if (m_iChannelNumber == -1) {
					if (m_iNumberToPlay == 0) {
						nextNumbers.push(0);
						m_iNumberToPlay = -1;
					}
				}
				if (m_iChannelNumber == -1 || Mix_Playing(m_iChannelNumber) != 1) {
					if (m_iNumberToPlay == -1 && nextNumbers.empty() == true) { // number finished
						m_bIsPlayingNumber = false;
						return;
					}
					if (nextNumbers.empty() == false) {
						m_aSndNum[nextNumbers.front()].play();
						m_iChannelNumber = m_aSndNum[nextNumbers.front()].getChannel();
						nextNumbers.pop();
					} else { // calculate numbers to play
						std::string sNum   = Util::toString(m_iNumberToPlay);
						int         length = sNum.length();
						int         subStrLength = ( (length-1) % 3) + 1;
						ESoundNumber sn = SND_NUM_NONE;
						switch ( (length-1) / 3) {
							case 1:  sn = SND_NUM_THOUSAND; break;
							case 2:  sn = SND_NUM_MILLION; break;
							case 3:  sn = SND_NUM_BILLION; break;
							default: sn = SND_NUM_NONE; break;
						}
						
						std::string sNumSub;
						for(int i = 0; i < subStrLength; i++) {
							sNumSub += sNum[i];
						}
						
						if (subStrLength >= 3) {
							nextNumbers.push(Util::parseInt(Util::toString(sNumSub[0])));
							nextNumbers.push(static_cast<int>(SND_NUM_HUNDRED));
						}
						if (subStrLength >= 2) {
							if (sNumSub.length() == 3) {
								sNumSub.erase(0,1);
							}
							if (Util::parseInt(sNumSub) >= 20) { //tys
								switch (Util::parseInt(std::string(1,sNumSub[0]))) {
									case 2: nextNumbers.push(static_cast<int>(SND_NUM_20)); break;
									case 3: nextNumbers.push(static_cast<int>(SND_NUM_30)); break;
									case 4: nextNumbers.push(static_cast<int>(SND_NUM_40)); break;
									case 5: nextNumbers.push(static_cast<int>(SND_NUM_50)); break;
									case 6: nextNumbers.push(static_cast<int>(SND_NUM_60)); break;
									case 7: nextNumbers.push(static_cast<int>(SND_NUM_70)); break;
									case 8: nextNumbers.push(static_cast<int>(SND_NUM_80)); break;
									case 9: nextNumbers.push(static_cast<int>(SND_NUM_90)); break;
									default: break;
								}
							}
							else if (sNumSub.length() == 2 && Util::parseInt(Util::toString(sNumSub[0])) != 0){ // teens
								nextNumbers.push(Util::parseInt(sNumSub));
							}
						}
						if (subStrLength == 1 || (subStrLength > 1 && Util::parseInt(sNumSub) > 20)) { // normal numbers (1 - 9)
							if (                 Util::parseInt(Util::toString(sNumSub[sNumSub.length() - 1])) != 0) {
								nextNumbers.push(Util::parseInt(Util::toString(sNumSub[sNumSub.length() - 1])));
							}
						}
						
						
						if (sn != SND_NUM_NONE)
							nextNumbers.push(static_cast<int>(sn));
						
						//adjust number
						for (int i = 0; i < subStrLength; i++) {
							sNum.erase(0,1);
						}
						
						//adjust numberToPlay
						if (sNum.length() > 0) {
							m_iNumberToPlay = Util::parseInt(sNum);
						} else {
							m_iNumberToPlay = -1; // ended
						}
					}
				}
			}
		}
	}
开发者ID:swantescholz,项目名称:coding,代码行数:87,代码来源:RoeAudioManager.cpp

示例3: pop

 static void pop (std::queue<T>& que) {
     que.pop();
 }
开发者ID:rberrens,项目名称:piPipes,代码行数:3,代码来源:generic_container.hpp

示例4: push

 static void push(std::queue<T>& que, U&& data) {
     que.push(data);
 }
开发者ID:rberrens,项目名称:piPipes,代码行数:3,代码来源:generic_container.hpp

示例5: ProcessPacket

void ProcessPacket( Packet *pack, int nsp_index)
{
	//double diff = pack->time - prev_time;
	//prev_time = pack->time;
	//printf("timediff = %.3f ms\n", 1000*diff);

	//printf("Processing Packet: type %i, nbytes %i, time %.3f\n", pack.type, pack.nbytes, pack.time);

	int display_chan = 0;

	switch( pack->type){

		case Packet::TYPE_SPIKE:
		{
		
			// add copy of spike packet to queue buffer
			SpikePacket *sp = (SpikePacket*)pack;
			SpikePacket sp_copy = *sp;
			spikeQueue.push(sp_copy);
			LARGE_INTEGER t_spikePack;
			QueryPerformanceCounter(&t_spikePack);
			stQueue.push(t_spikePack);

			break;	
		
		} //end case
		case Packet::TYPE_WAVEDATA:
		{
			printf("~");
			break;
		}
		case Packet::TYPE_GROUP:
		{
			GroupPacket *wave_pack = (GroupPacket*) pack;
			bool done = LFPData.AddSample(wave_pack->data);
			if (done) //we have enough samples to send onwards
			{
				if (overflow_possible)
					printf("LFP Overflow - Packet Lost\n");
				overflow_possible = true;
			}
			else
			{
				overflow_possible =  false;
			}
			break;
		}

		case Packet::TYPE_HEARTBEAT:
		{
			theCounter.GetAndResetCount( theCount, MAX_TOTAL_SPIKE_CHANS_PER_SOURCE);
			threshCounter.GetAndResetCount( threshCount, MAX_SPIKE_CHANS_PER_SOURCE);

			SendDigEvents(); // send first so that combiner will include in current sample
			SendCounts( pack->time, theCount, MAX_TOTAL_SPIKE_CHANS_PER_SOURCE, nsp_index);
			
			if(collect_LFP){
				SendLFPs(nsp_index, pack->time);
			}
			else{
				int buffer_length=0;
				LFPData.GetAndReset(lfpdata, &buffer_length);
			}

			SendStimSyncEvents();

			if(collect_snippets){
				SendSnippets();
				SendRejectedSnippets();
			}
			else{
				Overall_Spike_Count = 0;
				Snippet_Message_Number= 0;
				Overall_Rejected_Count = 0;
				Rejected_Snippet_Message_Number = 0;

			}	
			
			//printf(".");
			break;
		}
		case Packet::TYPE_STATUS:
		{
			StatusPacket *status_pack = (StatusPacket*) pack;
			double mega_bytes_received = ((double)status_pack->bytesReceived) / (1024.0 * 1024.0);

            if (status_pack->packetsDropped > 0)
                printf("x");
            else
                printf("S");

			TotalCounter.GetAndResetCount( TotalCount, MAX_CEREBUS_TOTAL_UNITS);

			break;
		}
		case Packet::TYPE_DIGITAL:
		{
			DigitalPacket *digital_pack = (DigitalPacket*) pack;
			
			// subtract bits that were already high
//.........这里部分代码省略.........
开发者ID:ediril,项目名称:BCI,代码行数:101,代码来源:SPM_Cerebus.cpp

示例6: queue_add

		void queue_add(TaskItem& item)
		{
			pthread_mutex_lock(&m_mutex);
			w_items.push(item);
			pthread_mutex_unlock(&m_mutex);
		}
开发者ID:Nadasua,项目名称:HBNews,代码行数:6,代码来源:AIO.c

示例7: CPremove

void CPremove(cvec dataC, int tIni, int nCarriers, int nOFDM_symbols, int Pre, int Post, std::queue<cvec> &OFDM_data){


  int pt=tIni;
  cvec aux(nCarriers), Pre1(Pre), Pre2(Pre);
  cvec Pre1conj(Pre), mult(Pre);
  cvec data(nCarriers);
  //cycle to Remove CP:
  
  for(int i1=0;i1<nOFDM_symbols;i1++){

    //cycle to get Prefix, OFDM sysmbol and Post fix:
    for(int i2=0; i2<Pre; i2++){
      Pre1.set(i2,dataC[pt+i2]);
    }
    //std::cout<<"Pre1="<<Pre1<<"\n";

    pt=pt+Pre;

    for(int i2=0;i2<nCarriers;i2++){
      aux.set(i2,dataC[i2+pt]);
    }
    //std::cout<<"aux="<<aux<<"\n";

    pt=pt+nCarriers-Pre;
    
    
    for(int i2=0; i2<Pre ;i2++){
      Pre2.set(i2,dataC[i2+pt]);
    }
    
    //std::cout<<"Pre2="<<Pre2<<"\n";

    pt=pt+Post+Pre;

    //Process data and store it in the queue:
   
    Pre1conj =itpp::conj(Pre1);
       
    mult= itpp::elem_mult(Pre1conj,Pre2); 	
  
    complex<double> sum=itpp::sum(mult);
    double nuOff=arg(sum)/(2*M_PI*nCarriers);
    //DispVal(nuOff);
    
    complex<double> arg1;
   
    for(int i3=0; i3<nCarriers; i3++){
      arg1=complex<double>(0,-1*2*M_PI*nuOff*i3);
      aux[i3]=aux[i3]*exp(arg1);
    }
    //DispVal(aux);
    data=itpp::fft(aux);
    //DispVal(data);
      //Inserte data in Processing queue:
   
    OFDM_data.push(data);

    //DispVal(i1);
    //DispVal(pt);
   
  }

 
  return;
}
开发者ID:tony2909,项目名称:green,代码行数:66,代码来源:rx_funct.cpp

示例8: kalmanPhase

/** Return a queue with the Pilot Phase filtered based on a scalar Kalman filter
 *
 * @pre:
 *    - Pilot: queue of vec's with the received pilots
 *    - nPilot: number of pilots per OFDM symbol
 *    - F, G and H: state model definiton
 *    - R1 and R2: User parameters of the Kalman -> covariance of the noise
 *    - x0: vector of matrix with the initialization of the kalman
 *    - Q0: initialization of the error covariance matrix 
 *
 * @post:
 *    - Pilots are now filter!
 */
std::queue<itpp::vec> kalmanPhase (std::queue<itpp::vec> Pilot, int nPilot, itpp::mat F, itpp::mat G, itpp::mat H, itpp::mat R1, itpp::mat R2, std::vector<itpp::mat> x0 , itpp::mat Q0){
  
 
  itpp::mat x_pred(2,1);
  itpp::mat y_pred(1,1);
  itpp::mat P_1(2,2);
  itpp::mat x_hat_1(2,1);
  itpp::mat Q_1(2,2); 

  std::queue<itpp::vec> filtPilot; 
  
  int PilotSizeIni=Pilot.size();
  std::vector<itpp::mat> xhat_filt_p(nPilot), Q(nPilot);
  //kalman first iterartion:
  
  itpp::vec y=Pilot.front(); //Take measurements from data
  Pilot.pop();
   for(int i=0; i<nPilot;i++){
      //one iteration of the kalman
      kalmanPhaseIteration ( y(i), R1, R2,  x0[i], Q0, F, G, H, &x_pred, &y_pred, &P_1, &x_hat_1, &Q_1 );
      //update xhatfilt and Q
      xhat_filt_p[i]=x_hat_1;
      Q[i]=Q_1;
    }
    //store new filtered pilot vector into queue:
   itpp::vec aux(nPilot);
   for(int i=0;i<nPilot;i++){
     aux.set(i,xhat_filt_p[i].get(0,0));
   }
   filtPilot.push(aux);
  
  //Kalman loop:
  for(int i1=1; i1<PilotSizeIni;i1++){
    itpp::vec y=Pilot.front(); //Take measurements from data
    Pilot.pop();
    for(int i2=0; i2<nPilot;i2++){
      //one iteration of the kalman
      kalmanPhaseIteration (y(i2),R1,R2, xhat_filt_p[i2], Q[i2], F, G, H, &x_pred, &y_pred, &P_1, &x_hat_1, &Q_1 );
      //update xhatfilt and Q
      xhat_filt_p[i2]=x_hat_1;
      Q[i2]=Q_1;
    }
    //store new filtered pilot vector into queue:
   itpp::vec aux(nPilot);
   for(int i=0;i<nPilot;i++){
     aux.set(i,xhat_filt_p[i].get(0,0));
   }
   filtPilot.push(aux);

  }

  //DispVal(Pilot.size());
  //DispVal(filtPilot.size());
  if(PilotSizeIni!=(int)filtPilot.size()){
    std::cout<<"Error in filtering!\n";
    exit(1);
  }

  return filtPilot;

}
开发者ID:tony2909,项目名称:green,代码行数:74,代码来源:rx_funct.cpp

示例9: PushCommand

void PushCommand(std::string cmd, std::string param) {
	lock_guard guard(frameCommandLock);
	frameCommands.push(FrameCommand(cmd, param));
}
开发者ID:zhoudianyou,项目名称:ppsspp,代码行数:4,代码来源:app-android.cpp

示例10: SystemToast

// Android implementation of callbacks to the Java part of the app
void SystemToast(const char *text) {
	lock_guard guard(frameCommandLock);
	frameCommands.push(FrameCommand("toast", text));
}
开发者ID:Edvaderprime33,项目名称:native,代码行数:5,代码来源:app-android.cpp

示例11: add

 void add( std::string name, uint64_t value ) {
     std::stringstream ssv;
     ssv << value;
     outputs.push( new Entry( name, ssv.str() ));
 }
开发者ID:zmahdavi,项目名称:grappa,代码行数:5,代码来源:DictOut.hpp

示例12: add_right

void add_right( int index ) {
  if( index + 1 < M * N && room_state[index + 1] == 0 ){
    q.push( index + 1 );
    room_state[index+1] = count;
  }
}
开发者ID:waitin2010,项目名称:Algorithm,代码行数:6,代码来源:castle.cpp

示例13: push

 void push(T&& new_value)
 {
     std::lock_guard<std::mutex> lock(_mtx);
     _data.push(std::move(new_value));
     _data_cond.notify_one();
 }
开发者ID:rafagaitan,项目名称:esat-multithreading,代码行数:6,代码来源:ThreadSafeQueue.hpp

示例14:

 ~DictOut( ) {
     if (!outputs.empty())
         std::cerr << "Warning: did not output DictOut" << std::endl;
 }
开发者ID:zmahdavi,项目名称:grappa,代码行数:4,代码来源:DictOut.hpp

示例15: notify_event

	void notify_event(const Ctrl& ctrl, uint32_t devnum=0) {
	  scoped_lock lock(guard_);
	  shared_ptr<event_ctrl<Ctrl> > p(new event_ctrl<Ctrl>(ctrl, devnum));
	  eventQueue_.push(p);
	  wakeup_.notify_one();
	}
开发者ID:venkatarajasekhar,项目名称:ssa,代码行数:6,代码来源:event.hpp


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