File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes queue or priority oueue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "queue or priority oueue" Watch "queue or priority oueue" New topic
Author

queue or priority oueue

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
what are the different between queue and priority oueue ?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3858

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.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
no i am asking in general datas structure.
V K Gupta
Ranch Hand

Joined: Aug 07, 2008
Posts: 55
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

Joined: Mar 24, 2008
Posts: 3858

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

Joined: Nov 25, 2008
Posts: 1225
how to implement a stack using two queues ?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: queue or priority oueue