本文整理汇总了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();
}
}
示例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();
}
示例3: pop
void pop(int& x) {
AppLock l(m);
while(Q.empty()) {
c.wait(l);
}
x = Q.front();
Q.pop();
}
示例4:
void operator<<(std::queue<_Tp,Range> lhs)
{
for(;!lhs.empty();){
std::cout<<lhs.front()<<token;
lhs.pop();
}
std::cout<<last_token<<std::flush;
}
示例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_);
}
}
示例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;
}
}
}
示例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 () ;
}
示例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 };
}
示例9: deleteNodes
void deleteNodes(std::queue<BruteNode *> &delQueue)
{
while (!delQueue.empty())
{
delete delQueue.front();
delQueue.pop();
}
}
示例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();
}
示例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();
}
示例12: cleanupArgs
void cleanupArgs()
{
while (!args.empty())
{
delete args.front();
args.pop();
}
}
示例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;
}
示例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;
}
示例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;
}