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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:59:05+00:00 2026-06-11T05:59:05+00:00

What data structure to use when I need to access an object by priority

  • 0

What data structure to use when I need to

  • access an object by priority – to dequeue
  • access an object by name/id to update the priority

With Java’s PriorityQueue, I can’t access a node directly by its name/id property can I?


I was thinking along the lines of use a priority queue, plus a TreeMap so I can search by name in log(n) time, then modify the priority. But I doubt the Queue will know of that? In that case, I need to remove and re-add the node? Is that worth the overhead? What complexity is it to remove/re-add a node?

  • 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-11T05:59:06+00:00Added an answer on June 11, 2026 at 5:59 am

    In that case, I need to remove and re-add the node?

    Yes.

    Is that worth the overhead?

    That depends on your requirements. Only you know that.

    What complexity is it to remove/re-add a node?

    Insert and remove from a PriorityQueue is O(log n).

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

Sidebar

Related Questions

I have the need to use a Stack-like data structure for a program that
I need to protect the access to a data structure in my class. As
A data structure that I use commonly in multi-threaded applications is a ConcurrentHashMap where
Is there a .NET data structure I could use for bidirectional lookup? Here's the
I wonder what is the best C# data structure I should use to sort
I want to use pprint's output to show a complex data structure, but I
I would like to know what kind of data structure (queue) I should use
Basically I need a data structure to store the temporary chatting messages on the
I have a question about the use of data structures such as ArrayLists in
Which data structure is most suitable for forward and backward webpage traversal in web

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.