possible to make expandable arrays/lists

BlitzMax Forums/BlitzMax Beginners Area/possible to make expandable arrays/lists

GamerTheHut(Posted 2006) [#1]
is it possible to make expandable arrays or lists?


GamerTheHut(Posted 2006) [#2]
err, i mean arrays, not lists :)


FlameDuck(Posted 2006) [#3]
Yes. Arrays can be expanded by using slices. However it is a very expensive operation, and if done often, a List, an associative array (TMap) or HashMap may be a better datastructure to use, in terms of speed.


GamerTheHut(Posted 2006) [#4]
ok ill look into it, only using it for the beginning of the program, no while it is running. thx


tonyg(Posted 2006) [#5]
You could create a list, do any expansion at the beginning of the program then use ListToArray for use within the game/app.


Dreamora(Posted 2006) [#6]
A quite fast way to do dynamic arrays is doing *2 /2 in slicing whenever needed (*2 if you need more slots than your array has, /2 if the half or less is used)