How to add multiply items to a list quickly?

BlitzMax Forums/BlitzMax Beginners Area/How to add multiply items to a list quickly?

Koekelas(Posted 2005) [#1]
How do I add multiply items to a list quickly? Say I have a type called myType and a list called myList. I want to add myType hundred times to myList. How do I do this quickly?


Thanks, Nicolas.


skn3(Posted 2005) [#2]
for i=0 until 100
    mylist.AddLast(mytype)
next



Koekelas(Posted 2005) [#3]
Thank you, but I don't get the result I expected. Say every instance of myType in myList contains an image and a random x and y value. If I iterate through myList in order to draw every image on it's corresponding x and y values I'm only seeing the first instance, what am I doing wrong?


Thanks, Nicolas.


skn3(Posted 2005) [#4]
Well you need to create 100 instances and add each one to the list. What you asked, would create 1 instance, and add it to the list 100 times.

do it like so...
for local i:int = 0 until 100
    mylist.AddLast(new mytype)
next



Koekelas(Posted 2005) [#5]
Thank you, you solved my problem.


Nicolas