Page 1 of 1
pointers and lists
Posted: Tue Apr 19, 2011 10:52 pm
by jerico2day
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
Posted: Tue Apr 19, 2011 11:15 pm
by Demivec
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.
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.
Re: pointers and lists
Posted: Tue Apr 19, 2011 11:17 pm
by STARGĂ…TE
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.
Re: pointers and lists
Posted: Wed Apr 20, 2011 12:26 am
by Demivec
@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.
Re: pointers and lists
Posted: Sat Apr 23, 2011 3:50 pm
by jerico2day
Great, thanks guys!