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
    14,314
    Blog Entries
    7
    Rep Power
    25

    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
    The only person who got everything done by Friday was Robinson Crusoe.

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

    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, 11: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
  •