Page 1 of 1

Linked list addition

Posted: Tue Nov 04, 2003 10:56 pm
by tinman
A command to remove the current element from a linked list but not free the memory would be nice.

*removed_element = RemoveElement(list())

Posted: Tue Nov 04, 2003 11:06 pm
by freak
Hum, how would you free the memory then, if at some point later, you want to?

Timo

Posted: Tue Nov 04, 2003 11:22 pm
by tinman
freak wrote:Hum, how would you free the memory then, if at some point later, you want to?
Magic.

Posted: Tue Nov 04, 2003 11:59 pm
by freak
tinman wrote:
freak wrote:Hum, how would you free the memory then, if at some point later, you want to?
Magic.
Ok, then, for speed reasons, i suggest adding a StartMagic() and StopMagic() command :lol:

Seriously: What's this good for?

Timo

Posted: Wed Nov 05, 2003 9:45 am
by Fred
I guess it could be used to put it back on the list later faster.

Posted: Wed Nov 05, 2003 10:10 am
by plouf
so if i understand correctly you only wand the pointer of the previous element to show two element forward ,if we knew how lsit are implement.... :wink:

Posted: Wed Nov 05, 2003 10:16 am
by LarsG
Wouldn't this create an extra overhead in the checking of a new element in the list?!? Meaning it has to check to see if an element allready was allocated, and then see if it's empty or not..

Come to think of it, it might be solved with an additional field in the list structure called "empty" or something.. just to set to null if it's allocated, but "realeased"...

Posted: Wed Nov 05, 2003 10:29 am
by plouf
if a) you keep a pointer telling you where the missing element exist
and b) chenge the pointer of the previouselement to point to the element the "deleted" elemnt point it will have no overhoult at all since that how linked list work they are a pointer to the previous element the structure itself and a pointer to the next element