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?
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
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.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: Does an element within a linked list/map keep its address forever?
map elements may change if it resizes.