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

  • Home
  • SEARCH
  • 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 7598461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:24:47+00:00 2026-05-30T22:24:47+00:00

Is there a data structure like a queue which also supports removal of elements

  • 0

Is there a data structure like a queue which also supports removal of elements at arbitrary points? Enqueueing and dequeueing occur most frequently, but mid-queue element removal must be similar in speed terms since there may be periods where that is the most common operation. Consistency of performance is more important than absolute speed. Time is more important than memory. Queue length is small, under 1,000 elements at absolute peak load.In case it’s not obvious I’ll state it explicitly: random insertion is not required.

Have tagged C++ since that is my implementation language, but I’m not using (and don’t want to use) any STL or Boost. Pure C or C++ only (I will convert C solutions to a C++ class.)

Edit: I think what I want is a kind of dictionary that also has a queue interface (or a queue that also has a dictionary interface) so that I can do things like this:

Container.enqueue(myObjPtr1);
MyObj *myObjPtr2 = Container.dequeue();
Container.remove(myObjPtr3);
  • 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-30T22:24:48+00:00Added an answer on May 30, 2026 at 10:24 pm

    I think that double-link list is exactly what you want (assuming you do not want a priority queue):

    1. Easy and fast adding elements to both ends
    2. Easy and fast removal of elements from anywhere

    You can use std::list container, but (in your case) it is difficult to remove an element
    from the middle of the list if you only have a pointer (or reference) to the element (wrapped in STL’s list element), but
    you do not have an iterator. If using iterators (e.g. storing them) is not an option – then implementing a double linked list (even with element counter) should be pretty easy. If you implement your own list – you can directly operate on pointers to elements (each of them contains pointers to both of its neighbours). If you do not want to use Boost or STL this is probably the best option (and the simplest), and you have control of everything (you can even write your own block allocator for list elements to speed up things).

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

Sidebar

Related Questions

Does there exist a cheat sheet for data structure like TreeMap, SortedMap, HashSet etc
I would like to know what kind of data structure (queue) I should use
I'm looking for a data structure that will act like a Queue so that
Is there any Queue data structure implementation that comes with C or will I
Is there an R data structure into which I can store a number of
Is there some data structure in Perl like LinkedHashMap in java? Or something LRU
I'm searching for an algorithm which will convert a data structure like the following
Is there any header file in c or c++ to implement data structure like
Is there a pretty printing function in Clojure that would output data-structures like lists
Are there any built-in C# data structures that are like a hash table but

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.