pointers and lists
-
jerico2day
- User

- Posts: 37
- Joined: Mon Jul 13, 2009 5:41 pm
pointers and lists
Hey all, I'm designing something using pointers to keep track of list items for speed reasons. I'm wondering if a pointers address will ever change in a list element? I've done some tests where I added and deleted elements and no other elements changed their pointer address, but I want to make sure this is actually the case over the runtime of a program.
Re: pointers and lists
List elements won't ever change addresses once they are added. So, unless you delete them and add them back they'll always be at the same address.jerico2day wrote:Hey all, I'm designing something using pointers to keep track of list items for speed reasons. I'm wondering if a pointers address will ever change in a list element? I've done some tests where I added and deleted elements and no other elements changed their pointer address, but I want to make sure this is actually the case over the runtime of a program.
Re: pointers and lists
You are right, an element remains as long as it exists its address!
This is different from the array to be increased with ReDim, hheir field-addresses can change, if the array is larger.
This is different from the array to be increased with ReDim, hheir field-addresses can change, if the array is larger.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: pointers and lists
@jerico2day: One additional note, you can also sort the elements in a Linked-List (or otherwise reorder them) and they will still be at the same addresses because only an element's links are changed and not its address.
-
jerico2day
- User

- Posts: 37
- Joined: Mon Jul 13, 2009 5:41 pm
Re: pointers and lists
Great, thanks guys!
