Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: returning nothing
|
Posted: May 10, 2002 7:05 PM
|
|
What do you mean it doesn't return the position? What does it return? What are you trying to accomplish? If it is supposed to get the position why isn't the method called getPosition() instead of newJobs(), which would lead us to believe that it instantiates an array of Job objects, or something?
More specifically, you assigned temp to a new instance of QueueNode, but then before using it, you replaced it with an assignment to start (which I assume is an instance variable). Then, from start, you traverse to previous, which seems counterintuitive (I would imagine going to the next node from the start node, or the previous node from the end, or last node). Did you also write the QueueNode class?
Anyway, here is a little more concise version of your code, keeping to the same conventions you have (that is, going from start to previous, rather than next):
public int getNodeCount()
{
int count = 0;
for( QueueNode temp = start; temp != null; temp = temp.previous )
count++;
return count;
}
|
|