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 5985415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:31:37+00:00 2026-05-22T22:31:37+00:00

I’m looking for the proper data structure for this scenario. I have boost available

  • 0

I’m looking for the proper data structure for this scenario. I have boost available to use.

The code was originally in C#, and I was using a queue there, but I don’t believe that was an appropriate choice, and there isnt a C++ equivalent for C#’s queue as far as I can tell. I’m looking at the following properties in terms of their frequency/importance:

  • Needs to have quick iteration
  • Need to be able to advance the structure quickly (i.e. When i pull an element off the the top, the next element should be the structure head)
  • Will occasionally be cleared then fully repopulated
  • Will occasionally be copied
  • Will not need to be sorted as the elements will be added in the correct order

The number of elements will be known at creation time and will be 50 to 200 elements. The structure will never hold more then this, but may occasionally hold less

I was considering using std::list, but with the need to clear then repopulate occasionally, this doesn’t seem to be a good option. When I create a list with a fixed size, then clear it, it loses the prefixed size doesn’t it? Is there some way to always keep the list size so it doesn’t have to deallocate/allocate memory?

I know boost has a queue data structure, but it isn’t iterable, and I’m not sure if it would have the same problem I had with std::list

Some suggestion on how to fit std::list into my problem or a more appropriate data structure would be helpful.

  • 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-05-22T22:31:38+00:00Added an answer on May 22, 2026 at 10:31 pm

    std::deque seems to meet all of your requirements.

    If performance is a real issue for you, you should read GMan’s answer to Pre-allocate space for C++ STL queue .

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

Sidebar

Related Questions

No related questions found

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.