3 Replies - 10967 Views - Last Post: 02 April 2009 - 02:29 PM Rate Topic: -----

#1 pansylea  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 29-November 08

sort priority queue ?

Posted 02 April 2009 - 12:30 PM

How do i sort a priority queue by the priority ???
Is This A Good Question/Topic? 0
  • +

Replies To: sort priority queue ?

#2 markhazlett9  Icon User is offline

  • Coding is a lifestyle
  • member icon

Reputation: 60
  • View blog
  • Posts: 1,666
  • Joined: 12-July 08

Re: sort priority queue ?

Posted 02 April 2009 - 01:39 PM

Like what are talking about priority queue? like the system queue? or a queue you have set up?
Was This Post Helpful? 0
  • +
  • -

#3 pansylea  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 29-November 08

Re: sort priority queue ?

Posted 02 April 2009 - 01:49 PM

i have 4 classes and a tester

-Task
(String taskDescription, String taskCategory, int taskUrgency, String taskDay, String taskMonth, int taskYear)
This class implements Comparable and has the following methods
get() and sets()
compareTo()
toString()


- ArrayStack
This class has the following methods
push()
pop()
peek()
isEmpty()
isFull()
toString()
length()

-PriorityQueue
This class has these methods
insert()
remove()
peek()
isEmpty()
isFull()
toString()
length()

Then the tester creates an array stack and fills it with tasks. it then searches for tasks to be completed today and is meant to be inserted into the priority queue. The most urgent task is then meant to be displayed and the priority queue is to be sorted by urgency.
Was This Post Helpful? 0
  • +
  • -

#4 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: sort priority queue ?

Posted 02 April 2009 - 02:29 PM

Your PriorityQueue class needs to implement the Comparable interface: Comparable

Note Java has a PriorityQueue class: PriorityQueue
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1