[fpc-pascal] about dynamic array
spir ☣
denis.spir at gmail.com
Thu May 6 11:39:11 CEST 2010
Hello,
Where can one find information on types like dynamic array? Also, on funcs or procs that apply on them, like setLength & copy. If the answers to the following questions are somewhere, just tell me...
* Can one rely on the fact that setLength keeps existing data (in the range of the new size), both when up- and down-sizing? Or do my trials work only because the pointed memory has not yet been overwritten?
* How is resizing actually performed (is the data moved to a newly allocated area)?
* Does copy onto a dynamic array automatically resize (setLength), even if the target is greater than needed? (I would like no.)
* Can one set the first index where to copy on the target array? (eg to join 2 arrays into a greater one, or to extend an existing one that has free space at tail)
* Can one use copy from/to a *static* array? (If no, why not?)
* What other differences with static array, if any? (Aside the fact that one does not need to explicitely reallocate and copy on resizing.)
For Christmas:
* Can one add or remove an element --at the end? (And have the array behave accordingly.)
* Can one add or remove an element --anywhere? (And have the array behave accordingly.)
If the answers to last 2 questions is "only every 29th of februar", how can one have a "flexible" array? Is there something like that in stock? Would you implement it on top of dynamic array, or rather from scratch on top of static array (since the "dynamicity" does not seem very helpful)?
Denis
________________________________
vit esse estrany ☣
spir.wikidot.com
More information about the fpc-pascal
mailing list