If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

creating my own linked list class - very new to this

I have tried searching the forum (and google) and can't seem to come with anything that solves my problem. either that or i just really dont get it. My professor was to supply a class that creates an object of a class that I will create called PriorityQueue.

PriorityQueue to my understanding is to take the place of the LinkedList class as i was strictly instructed not to use the LinkedList class. What i am wondering is this, with an array i could use index's within my PriorityQueue class and wouldn't have to worry. but not without being able to use indexes, how am i supposed to keep track of all the names that can be entered by the user? After i enter more than 2 names, how is the program to keep track of any new names entered?

The first object should hold the first node for as long as the program runs. But after i take in a few more names from the user, how am i supposed to know what was ever in the second node? Since tempNode gets new data everytime a user enters a name, and we keep moving position up the list as we get names, but its really not even a list. im just changing the values of .data. Can anyone understand what I'm saying? Would an iterator be of use here or since i'm not using java's linked list class it wouldn't work?

I'm so confused right now. Most of the examples i see online are for classes that use either the java supplied linkedlist or create their own and do everything within that class.

is the object staff supposed to represent the linked list itself? in order for the linked list to work, there must be multiple objects stored in some location. each object has a reference to the object after it. (im working a singly linked list). but they have to be stored somewhere in my program. does staff represent that "location" where my nodes are stored?

Yes, the object, staff, is the location where all of your data gets put.

//this inserts a name on the priority queue
staff.insert(name);

Currently, your code only puts it at the front of the list (first node). However, I'm assuming you will change the insert method after you understand what is going on...

I would look at your textbook or lecture notes on what he actually wants your priority queue to do (what is the priority, is it just making the list sorted? Or is there some other way of determining that Bill comes before Susan?) Oh, wait. I see that insert takes a Comparable, which means all objects inserted must implement compare()...seems like that should be the method to use to determine where in the list a new name should be inserted! If so, then data should also be of type Comparable, not Object.

thankyou. yea that did help. i just couldn't figure out why or how or where the nodes were getting stored. its a little complicated at first but its ok now. thanks again.

now i have just one other problem. in a second class that the teacher has given me, i can't seem to compile. I get an error that an object of type Job (class i created) can't be passed into insert method of my PriorityQueue class that is accepting Comparable objects. However, the insert method is required to accept this kind of object. What do you guys think?