Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8004781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:01:02+00:00 2026-06-04T17:01:02+00:00

I have a queue. If it exceeds X size, when I push an element

  • 0

I have a queue. If it exceeds X size, when I push an element I want to remove the first element of the queue. (the last element that would get popped and the first element pushed in)

void ClientPlayerManager::queueTableMessage( const std::string& playerName, const std::string& message )
{
    m_tableQ.push(std::make_pair(playerName,message));

    if(m_tableQ.size() > m_maxTableMessages)
    {
        //m_tableQ.pop_back(); does not exist
    }
}

Is there a way to do this with a std queue?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:01:03+00:00Added an answer on June 4, 2026 at 5:01 pm

    You can use a std::deque instead of a std::queue, which supports push_front, push_back, pop_front, and pop_back. This also allows for random access throughout, but you can just ignore that and treat the deque like a double-ended queue. (In fact, deque is short for double-ended queue).

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Queue object that I need to ensure is thread-safe. Would it
I have a queue (from the Queue module), and I want to get indexed
I have declared: queue<int, list<int> > Q After a series of calls: Q.push(37); Q.pop();
I have a Queue that contains a collection of objects, one of these objects
I have a queue structure that is being used by several pthreads. The threads
I have a queue of users(string of emails) a in c# and I want
I have a problem with queues in my program. Having one queue I would
What happens when front==rear in circular queue is queue have one element or is
I have a queue that should be used by some classes. it is the
I have a Microsoft Message Queue that gets populated with messages. If there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.