Linked list addition

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Linked list addition

Post 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())
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Hum, how would you free the memory then, if at some point later, you want to?

Timo
quidquid Latine dictum sit altum videtur
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

freak wrote:Hum, how would you free the memory then, if at some point later, you want to?
Magic.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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
quidquid Latine dictum sit altum videtur
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I guess it could be used to put it back on the list later faster.
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Post 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:
Christos
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post 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"...

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Post 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
Christos
Post Reply