Priority Queue implemented as LinkedList api class java



Hello all, its been a while. cheers to all. Anyways, I have been struggling
with what is suppose to be an "Easy" problem. Someone once told me that
things are easy only when obvious. I guess my problem then is this isn't
obvious to me. I have to implement a priority queue by means of the
LinkedList class found in the api.
I know the following:

I will have to use generics(which i will use after I get this working first
with integer data types)
When generics is in play I will have to implement the Comparable interface
with the compareTo method to compare keys.(which should be fun)
next,
I will have an Entry class as an innerclass within my Priority queue class.
I will have to print out both the key and value pairs based on minimum
key(highest priority).
However, by using the LinkedList class, I am almost certain I have to use an
iterator to step through all entries in the PQ and return the one with the
minimum key.
I guess I don't really understand how I am going to do this.
I am thinking store the first entry in a temp variable and compare the rest
of the entries with this one in regards to the key? When the minimum key is
found return the entry corresponding to it
I also tried to insert entries based on their keys into the list, however,
when I did this I got size 0 index 1000 error. Furthermore, if someone could
please lead a helping hand it would be much appreciated. I know this must
seem very trivial, but it isn't for me. At the moment I think implementing
this from scratch or with an array would have been much easier.

Thanks Mike


.



Relevant Pages

  • Re: Priority Queue implemented as LinkedList api class java
    ... I have to implement a priority queue by means of the LinkedList class found in the api. ... When generics is in play I will have to implement the Comparable interface with the compareTo method to compare keys. ... However, by using the LinkedList class, I am almost certain I have to use an iterator to step through all entries in the PQ and return the one with the minimum key. ...
    (comp.lang.java.help)
  • Re: user-level security
    ... >To use their login and compare it to table entries, ... >CurrentUser() function. ...
    (microsoft.public.access.security)
  • Re: scaling fxn unique to dataset
    ... Daniel Boone wrote: ... all entries are saved as "data". ... compare the uniqueto wordlist to return the number ... If data and wordlist are cell strings, ...
    (comp.soft-sys.matlab)
  • RE: Excel 2003 - Numbers vs text
    ... All entries with just numbers should be text and all entries that contain ... alpha characters will still be text. ... I have two tables each with account numbers. ... I have tried just about everything to get a good compare to no ...
    (microsoft.public.excel)
  • Re: user-level security
    ... To use their login and compare it to table entries, ... CurrentUser() function. ...
    (microsoft.public.access.security)