Page 1 of 1

Does an element within a linked list/map keep its address forever?

Posted: Fri Aug 19, 2022 11:25 pm
by jacdelad
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.)?

Re: Does an element within a linked list/map keep its address forever?

Posted: Sat Aug 20, 2022 12:20 am
by Demivec
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.

Re: Does an element within a linked list/map keep its address forever?

Posted: Sat Aug 20, 2022 12:47 am
by jacdelad
Yeah, that's what I suspected, thanks.

Re: Does an element within a linked list/map keep its address forever?

Posted: Sat Aug 20, 2022 1:36 am
by idle
map elements may change if it resizes.