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


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

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


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

示例1: cleanupStrings

void cleanupStrings()
{
    while (!heapStrings.empty())
    {
        free(heapStrings.front());
        heapStrings.pop();
    }
}
开发者ID:jslick,项目名称:matrixvm,代码行数:8,代码来源:assembler_util.cpp

示例2: wait_and_pop

 void wait_and_pop(T& value) {
     std::unique_lock<std::mutex> lock(m_mutex);
     m_data_available.wait(lock, [this] {
         return !m_queue.empty();
     });
     value=std::move(m_queue.front());
     m_queue.pop();
 }
开发者ID:Gozhack,项目名称:osrm-backend,代码行数:8,代码来源:queue.hpp

示例3: pop

	void pop(int& x) {
		AppLock l(m);
		while(Q.empty()) {
			c.wait(l);
		}
		x = Q.front();
		Q.pop();
	}
开发者ID:AmkG,项目名称:hl,代码行数:8,代码来源:producer_consumer_test.cpp

示例4:

 void operator<<(std::queue<_Tp,Range> lhs)
 {
         for(;!lhs.empty();){
                 std::cout<<lhs.front()<<token;
                 lhs.pop();
         }
         std::cout<<last_token<<std::flush;
 }
开发者ID:falgon,项目名称:miko-lib,代码行数:8,代码来源:rall_cout.hpp

示例5: setCompressed

void PartialMerkleTree::setCompressed(std::queue<uchar_vector>& hashQueue, std::queue<bool>& bitQueue, unsigned int depth)
{
    depth_ = depth;

    if (hashQueue.empty() || bitQueue.empty()) {
        throw std::runtime_error("PartialMerkleTree::setCompressed - Invalid compressed partial merkle tree data.");
    }

    bool bit = bitQueue.front();
    bits_.push_back(bit);
    bitQueue.pop();

    // We've reached a leaf of the partial merkle tree
    if (depth == 0 || !bit) {
        root_ = hashQueue.front();
        merkleHashes_.push_back(hashQueue.front());
        if (bit) txHashes_.push_back(hashQueue.front());
        hashQueue.pop();
        return;
    }

    depth--;

    // we're not at a leaf and bit is set so recurse
    PartialMerkleTree leftSubtree;
    leftSubtree.setCompressed(hashQueue, bitQueue, depth);

    merkleHashes_.swap(leftSubtree.merkleHashes_);
    txHashes_.swap(leftSubtree.txHashes_);
    bits_.splice(bits_.end(), leftSubtree.bits_);

    if (!hashQueue.empty()) {
        // A right subtree also exists, so find it
        PartialMerkleTree rightSubtree;
        rightSubtree.setCompressed(hashQueue, bitQueue, depth);

        root_ = sha256_2(leftSubtree.root_ + rightSubtree.root_);
        merkleHashes_.splice(merkleHashes_.end(), rightSubtree.merkleHashes_);
        txHashes_.splice(txHashes_.end(), rightSubtree.txHashes_);
        bits_.splice(bits_.end(), rightSubtree.bits_);
    }
    else {
        // There's no right subtree - copy over this node's hash
        root_ = sha256_2(leftSubtree.root_ + leftSubtree.root_);
    }
}
开发者ID:ciphrex,项目名称:mSIGNA,代码行数:46,代码来源:MerkleTree.cpp

示例6: execute

	//Entry point for pool threads.
	void execute()
	{
		while( true )
		{
			//Wait on condition variable while the task is empty and the pool is
			//still running.
			boost::unique_lock< boost::mutex > lock( mutex_ );
			while( tasks_.empty() && !stop_ )
			{
                cv_task_.wait( lock );
			}

			// Copy task locally and remove from the queue. This is done within
			// its own scope so that the task object is destructed immediately
			// after running the task. This is useful in the event that the function
			// contains shared_ptr arguments bound via bind.
			if( !tasks_.empty() )
			{
				++busy_;
				boost::function< void() > task = tasks_.front();
				tasks_.pop();

				lock.unlock();

				//Run the task.
				try
				{
					task();
				}
				catch( const std::exception& )
				{
					//Suppress all exceptions
				}

				// Task has finished, so increment count of available threads
				lock.lock();
				++processed_;
				++available_;
				--busy_;
				cv_finished_.notify_one();
			}
			else if( stop_ ) {
				break;
			}
        }
    }
开发者ID:oim5nu,项目名称:Programming-Resource,代码行数:47,代码来源:threadpool.hpp

示例7: wait_and_pop

 void wait_and_pop ( Data& value )
 {
    boost::mutex::scoped_lock lock ( _mutex ) ;
    while ( _queue.empty () )
       _cond.wait ( lock ) ;
    value = _queue.front () ;
    _queue.pop () ;
 }
开发者ID:2015520,项目名称:SequoiaDB,代码行数:8,代码来源:ossQueue.hpp

示例8: push

 std::pair<size_t, size_t> push(pair_type && pair, boost::asio::io_service & main_service)
 {
     auto empty = _sessions.empty();
     _sessions.push(std::move(pair));
     if (empty)
         main_service.post(std::bind(&auth_queue::next, this));
     return { _sessions.size(), _counter };
 }
开发者ID:Ryuuke,项目名称:desperion,代码行数:8,代码来源:auth_queue.hpp

示例9: deleteNodes

void deleteNodes(std::queue<BruteNode *> &delQueue)
{
	while (!delQueue.empty())
	{
		delete delQueue.front();
		delQueue.pop();
	}
}
开发者ID:pwag42,项目名称:moba_source---2013,代码行数:8,代码来源:aStarBruteSearch.cpp

示例10: wait_and_pop

 void wait_and_pop(T& value)
 {
     std::unique_lock<std::mutex> lk(mut);
     data_cond.wait(lk,[this]{return !data_queue.empty();});
     value=data_queue.front();
     data_queue.pop();
     empty_cond.notify_one();
 }
开发者ID:Percona-Lab,项目名称:MetricBench,代码行数:8,代码来源:tsqueue.hpp

示例11: waitPop

	// wait and pop
	void waitPop(T& value) {
		std::unique_lock<std::mutex> lock(mtx_); // GUARD
		while (queue_.empty()) {
			conditionvar_.wait(lock); // WAIT
		}
		value = queue_.front();
		queue_.pop();
	}
开发者ID:bailey-lab,项目名称:bibseq,代码行数:9,代码来源:ConcurrentQueue.hpp

示例12: cleanupArgs

void cleanupArgs()
{
    while (!args.empty())
    {
        delete args.front();
        args.pop();
    }
}
开发者ID:jslick,项目名称:matrixvm,代码行数:8,代码来源:assembler_util.cpp

示例13: main

int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int i;
		int flag1=1,flag2=1,flag3=1;
		while(!ty1.empty())ty1.pop();
		while(!ty2.empty())ty2.pop();
		while(!ty3.empty())ty3.pop();
		int order,x;
		for(i=1;i<=n;i++){
			scanf("%d%d",&order,&x);
			if(order==1){
				ty3.push(x);
				ty2.push(x);
				ty1.push(x);
				}
			else {
				if(flag3&&!ty3.empty()){
					if(ty3.top()==x)ty3.pop();
					else flag3=0;
					}
				else flag3=0;
				
				if(flag2&&!ty2.empty()){
					if(ty2.top()==x)ty2.pop();
					else flag2=0;
					}
				else flag2=0;
				
				if(flag1&&!ty1.empty()){
					if(ty1.front()==x)ty1.pop();
					else flag1=0;
					}
				else flag1=0;
				}
			}
		int sum=flag1+flag2+flag3;
		if(sum>=2)printf("not sure\n");
		else if(sum==0)printf("impossible\n");
		else if(flag1)printf("queue\n");
		else if(flag2)printf("priority queue\n");
		else printf("stack\n"); 
		}
	return 0;
	}
开发者ID:JintianGo,项目名称:Training,代码行数:45,代码来源:11995+-+I+Can+Guess+the+Data+Structure.cpp

示例14: try_pop

		bool try_pop(T &value)
		{
			std::lock_guard<std::mutex> lk(mut);
			if(data_queue.empty())
				return false;
			value = std::move(data_queue.front());
			data_queue.pop();
			return true;
		}
开发者ID:ykevin,项目名称:KevinNote,代码行数:9,代码来源:queue.cpp

示例15: lk

		std::shared_ptr<T> try_pop() 
		{
			std::lock_guard<std::mutex> lk(mut);
			if(data_queue.empty())
				return std::shared_ptr<T> ();
			std::shared_ptr<T> res(std::make_shared<T>(std::move(data_queue.front())));
			data_queue.pop();
			return res;
		}
开发者ID:ykevin,项目名称:KevinNote,代码行数:9,代码来源:queue.cpp


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