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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:57:48+00:00 2026-05-14T00:57:48+00:00

I need a priority queue where I can increase or decrease the priority key.

  • 0

I need a priority queue where I can increase or decrease the priority key. So boost::mutable_queue seemed perfect despite the lack of documentation.

The problem is that I need to iterate at some point over all the elements in the queue. How can I do that?

Or is there an othe data structure that would work (preferably in boost)?

  • 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-14T00:57:48+00:00Added an answer on May 14, 2026 at 12:57 am

    Queues are not for iteration. The whole point of a queue is that you can only ever look at the element at the front of the queue.

    If you want to iterate then I suggest just using an std::set, which is ordered. When you want to modify an element, you’ll have to remove it and reinsert it with the new key. You can get the highest priority element using mySet.begin() (that returns an iterator to it).

    Ideally, you’ll want to use a heap. STL provides functions for making heaps, and that’s what the std::priority_queue uses. However, you can’t modify keys in the heap because there is no interface for it.

    If you manage the heap yourself then you can. However, you’ll need to make use of the std::__adjust_heap function from <heap.h>, which is undocumented. You can read all about why this function is undocumented in this interview with Alexander Stepanov (inventor of the STL). It had to be “removed” because apparently the STL was too big, which is also what happened to hash maps from the original standard.

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

Sidebar

Related Questions

I need some kind of priority queue to store pairs <key, value> . Values
I need a priority queue, I guess in the framework, CHMutableArrayHeap and CHBinaryHeap can
I need B class to have a min priority queue of AToTime objects. AToTime
I need a Max-Priority Queue data structure. Looking in Java's Priority Queue I noticed
I need to implement a priority queue in C programming using singly linked list.
How can I remove an arbitrary item from a priority queue. Suppose I have
Possible Duplicate: How can I implement decrease-key functionality in Python's heapq? Hi, I'm using
I need to use a priority queue in my Python code, and: am looking
I have implemented Priority Queue interface for making heap. Can you tell me how
so I am having trouble implementing priority queue. For a priority queue, I need

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.