Linked Lists
could someone explain to me how this works? I have never used link list''s before. It''s taken from the SimpEngine.
if (parentNode->childNode)
{
prevNode = parentNode->childNode->prevNode;
nextNode = parentNode->childNode;
parentNode->childNode->prevNode->nextNode = this;
parentNode->childNode->prevNode = this;
}
~Steve~
Here''s the idea of linked lists...
Since you have a "this", this is obviously a function belonging to a class, and it looks like that "parentNode" is a parameter to the function.
Now in this example, a simple node looks like this:
That is to say, whenever you access "childNode" of any node, you''re jumping forward in the linked list, and "prevNode" jumps back one node in the list.
So to figure out exactly what it does, draw out the list of what all the pointers refer to, and then draw out all of the things done to the list.
Hope this helps!
~ Dragonus
|
Since you have a "this", this is obviously a function belonging to a class, and it looks like that "parentNode" is a parameter to the function.
Now in this example, a simple node looks like this:
|
That is to say, whenever you access "childNode" of any node, you''re jumping forward in the linked list, and "prevNode" jumps back one node in the list.
So to figure out exactly what it does, draw out the list of what all the pointers refer to, and then draw out all of the things done to the list.
Hope this helps!
~ Dragonus
Instead of trying to incorporate your own linked lists, why not use C++''s standard template library...
It has its own doubly-linked list class
just include
It has its own doubly-linked list class
just include
Or even better, use the STL vectors...
Just an idea...
Use it, don''t use it

I don''t like lists simply because of those blasted iterators. I never did figure them out enough to be comfortable with them.
is nice though, however, for some strange reason, on the project I''m working on (don''t ask me why), I get linker errors whenever I try to load that in, as well as half of the other std libraries... grrrrrr...
~ Dragonus
~ Dragonus
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement