Hello,
when I get the address of an element within a linked list or map, does the address to this element always stay the same (as long as I don't use MergeList(), CopyList(), etc.)?
Does an element within a linked list/map keep its address forever?
Does an element within a linked list/map keep its address forever?
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: Does an element within a linked list/map keep its address forever?
Yes linked-list elements will remain at the same address. It should be safe even after MergeList() also. Only links are changed when rearranging list elements not the addresses of the elements. That's why they are called 'linked' lists.
Map elements may change.
@Edit: My first response ignored Map elements.
Map elements may change.
@Edit: My first response ignored Map elements.
Last edited by Demivec on Sat Aug 20, 2022 2:06 pm, edited 1 time in total.
Re: Does an element within a linked list/map keep its address forever?
Yeah, that's what I suspected, thanks.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: Does an element within a linked list/map keep its address forever?
map elements may change if it resizes.