• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

queue or priority oueue

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what are the different between queue and priority oueue ?
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

what are the different between queue and priority oueue ?



Queue is an interface whereas PriorityQueue is one of the implementations and there are few more.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no i am asking in general datas structure.
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Queue is an Interface present in java.util.Queue. Queue supports all Collections methods and other methods like
peek() : returns the highest priority queue and do not removes from the queue.
poll() : returns the highest priority queue and removes from the queue
offer(): add elements to the Priority Queue

These 3 methods are present only in Queue Interface. LinkList class also implements Queue Interface.

PriorityQueue : Is added in Java 5, PriorityQueue (PQ) is different from normal queue (FIFO) as PQ maintains the list as Priority IN and Priority OUT, the elements are ordered either in natural ordering or using comparator.


 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

aruna sameera wrote:no i am asking in general datas structure.



Queues typically order elements in a FIFO (First-In-First-Out) and PriorityQueue orders the element using the provided comparator or the natural ordering of the elements. Check those links I gave above.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to implement a stack using two queues ?
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

aruna sameera wrote:how to implement a stack using two queues ?

It would have been better to start a new thread, since that is a new subject.

And we don't simply give out such answers: you would do well to search and find a tutorial about the data structures for stacks and queues. Then tell us what you have learned and concluded, and we'll see what we think of it
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic