Results 1 to 3 of 3
  1. #1
    MasterCRB is offline Member
    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Default Access a particular element in a priority queue?

    I need to be able to access any element within a priority queue without the use of peek() and poll(), is this actually possible? Can't seem to find answers anywhere

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,375
    Blog Entries
    7
    Rep Power
    20

    Default Re: Access a particular element in a priority queue?

    A queue is a Collection so you can copy its contents over to another Collection (a List mayhap), and get(int i) all you want.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,759
    Rep Power
    7

    Default Re: Access a particular element in a priority queue?

    The whole point of a queue is that only the first element can be processed/accessed. If you need to access any element anywhere in the queue then you shouldn't using a queue in the first place. Or your design smells.

Similar Threads

  1. Replies: 1
    Last Post: 04-16-2012, 10:40 AM
  2. Priority Queue Implementation
    By cylus99 in forum New To Java
    Replies: 1
    Last Post: 12-20-2011, 10:48 PM
  3. Priority Queue
    By fam2315 in forum New To Java
    Replies: 5
    Last Post: 06-29-2011, 03:10 AM
  4. Priority Queue with explicit priority
    By lsk in forum Advanced Java
    Replies: 4
    Last Post: 06-10-2011, 07:16 PM
  5. Priority Queue
    By Suende in forum New To Java
    Replies: 19
    Last Post: 04-25-2011, 08:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •