pointer fun!

soccerbud34

Senior member
Nov 15, 2001
747
0
0
i have an assignment in which i have to use a linked list ot create a SparseMatrix but for some reason my linked list is broken ... i.e. null pointers everywhere ....

anyone willing to give me a hint or two?
 

Nil

Senior member
Mar 16, 2001
447
0
0
Does anyone else feel like the portions of a cup O pudding are to small. I mean, you have to eat two of the damn things!


Sorry, I posted this when the title read "Ignore this" and decided to get my nef on..
 

soccerbud34

Senior member
Nov 15, 2001
747
0
0


<< i love pointers! what can i help you with? >>



here is my problem, i have broken links everywhere in my linked list.... <sigh>
and you know how it goes with linked list and messed pointers ... one messed up pointer = deleting the whole linked list ....

here is my problem...

//prevNode and tempNode are RowNode objects
public class RowNode
{ public RowNode nextRow;
public int iMyRow;
public CellNode firstCell;
}



here is my lines of code ...

if(newRow == true )
{ prevNode.nextRow = tempNode;
prevNode = tempNode;
tempNode = new RowNode();
newRow = false;

}

if my code worked correctly, i have should have 6 RowNode objects linked together,
But for some reason, my linked list breaks and i have exact *1* RowNode object in my linked list, the very last one ...

any idea what i did wrong in my lines of code?



 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
i need to see all the code

i cant tell whats happening with out seeing the declarations or the rest of the code.