This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

queue or priority oueue

 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are the different between queue and priority oueue ?
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • 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.
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i am asking in general datas structure.
 
V K Gupta
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • 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: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • 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.
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to implement a stack using two queues ?
 
Campbell Ritchie
Sheriff
Pie
Posts: 48980
60
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic