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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:22:35+00:00 2026-05-28T19:22:35+00:00

I have a PriorityQueue containing references to some objects. When I initially insert the

  • 0

I have a PriorityQueue containing references to some objects. When I initially insert the elements into the priority queue the ordering is maintained by the data structure. Now after a remove operation I update some of the references which are being held by the priority queue. Ideally this requires a reheapify operation on the priority queue but as is obvious since I am modifying selected references externally a reheapify cannot be triggered. So what is the best way to ensure that I am able to get the advantage of a heap like fast extract max in the presence of modifications to arbitrary elements inside the queue? I see I need a better data structure?

To be more specific I need an implementation of something like a Fibonacci heap in Java.
http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
Is that available?

  • 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-28T19:22:36+00:00Added an answer on May 28, 2026 at 7:22 pm

    You can use your own tree that allows duplicate elements instead of heap.
    Easier though, you can use TreeMap<PriorityKey, LinkedHashSet<Value>>.
    All operations are O(log priorityType):

    • adding is get(priority).add(value), if get returns null, put(priority, new LinkedHashSet())
    • removing an arbitrary element is similar, except needs to remove the priority out of the map if the Set is empty.
    • poll() is

    —

    Entry<PriorityKey, LinkedHashSet<Value>> e = map.firstEntry(); 
    if (e==null) return null; 
    Iterator<Value> i = e.getValue().iterator(); 
    Value v = i.next(); //must always have at least one element.
    i.remove(); 
    if (!i.hasNext()) map.remove(e.getKey());
    return v;
    

    Still if you need to change the priority you have to remove and add the element.

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

Sidebar

Related Questions

I have priority queue which sorts elements by some value(lets name it rating). I
I need B class to have a min priority queue of AToTime objects. AToTime
Suppose that I have a priority queue which removes elements in increasing order, and
I want to have a priority queue with custom ordering, but lazy as I
Consider a std::priority_queue where N elements have the same priority. Now consider some pop()
Lets say I am writing Dijkstra's Algorithm , and I have a priority queue
I have a class that uses priority queue to display 5 strings in ascending
I have created a priority queue using the Java API and I want to
For example we have priority_queue<int> s; which contains some elements. What will be correct
I have a problem with stl priority queue.I want to have the priority queue

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.