Lets say you have a struct like this:
struct Node
{
ItemClass Item;
Node* next;
};
Now lets say you have 100000 Items. I know 100000 items sounds like a lot im using this as an example. Now you have to go through it like this:
while(LinkedItems->next)
{
CurrentItem = CurrentItem->next
}
Now to my knowledge that could get slow if you are going through the list a lot. But would this make it faster?
add a long ID. Now lets say I wanted to goto item 4500. Would this be faster??
long ID;
int IDRemains
int i;
ID = 4500;
IDRemains = ID % 5;
ID = ID / 5;
for(i = 0; i < ID; i++)
{
CurrentItem = CurrentItem->next->next->next->next->next;
}
if(IDRemains != 0)
{
For(i = 0; i < IDRemains; i++)
{
CurrentItem = CurrentItem->next;
}
}
Kinda after posting and coding I believe my second way is slower because it uses more code. But GameDev has helped me a lot so far so maybe Im right the first time. Thx.
Jeff D
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton
Edited by - Jeff D on January 31, 2002 8:36:00 AM
Edited by - Jeff D on January 31, 2002 8:37:19 AM
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton