Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2004, 11:35 PM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code in Java for priority queue

Hi
   I have to create one interface named IPriorityQ which contain the priorityQ. And the priorityQ must be able to check if the queue is empty, if it is full, add a queue, remove from queue and the number of size that returns the number of a element left in a queue.
  Also I have to create a class called PriorityQ that implements tbe Interface IPriorityQ. The priority quere here is to be implemented with an array of 3 circular queues - one fore each level of prioirty . this arrays has to be instance variable in this class. An empty circular queue is to be created and put at each element of the array. I have to include get and set methods also. I have 3 priority 1,2,and 3 and I have to sort in descending order as priority 3 should be in the top. Can u please give me some idea about the code. I have to do this on java
 Thanks

 
Old May 13th, 2004, 06:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This sounds like a homework assignment. If it is, you should probably ask your instructor, teacher's assistant, homework tutor, etc... for help. You can also research priority queues online and look for tutorials.

The interface class is easy:

public interface IPriorityQueue
{
    bool isEmpty();
    bool isFull();

    void push(Object o); // add to queue
    Object pop(); // remove from queue

    int size();
}

Then you'll need to define your class and implement the above functions:

public class PriorityQueue implements IPriorityQueue
{
    // interface functions are implemented here
}


I can't guarantee that all my syntax is correct, it's been a while since I've used java. C++ uses abstract base classes with pure virtual functions to achieve creating an "interface" class.


Take care,

Nik
http://www.bigaction.org/
 
Old May 15th, 2004, 05:28 AM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ty for the answer but the question i was confusing was another one like in an office they got level 1,2 and 3 and in level 1 there are many people working and the people have their name address position etc. and now I have to store this level 1,2 and 3 in array in such a way that when I search for array 1 then it will show me all the details of the people working in level 1. When I do array 2 then it should give me all the people working in level 2. Can u give me idea how can I do this. I will be very thankful for your help

 
Old November 13th, 2004, 08:08 PM
Registered User
 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi, ive also got a question abt priority queue. can i use it to implement a task scheduler? basically, the sheduler has to return a task with the earliest time stamp and the task aren't ordered. will it be the best data structure to use to implement it? thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Code - Wrox - Beginning JAVA - Ivor Horton ponguru Java Databases 3 May 18th, 2006 12:30 PM
bugbase: priority display in addedit is always 3 Far BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 April 25th, 2006 01:29 PM
Set base priority of exe lmadhavi Visual C++ 0 September 6th, 2004 05:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.