Lists

BlitzMax Forums/BlitzMax Beginners Area/Lists

TwoCorin517(Posted 2008) [#1]
I am in need of a little help. I'm writing a program which requires a container that can expand, while being able to retain the former information. It would seem like a List would be the way to go. But I can't seem to figure out how a List stores info. Does it merely link to info, or can it actually store it.

Can I create a Local object, and add it to a list, and then have that object be destructed while retaining the info in the list?


Gabriel(Posted 2008) [#2]
No.


tonyg(Posted 2008) [#3]
I'm writing a program which requires a container that can expand,
OK, that would be lists and arrays (using slicing) and maps. Depending on how you want to access the data lists seem a viable choice.

But I can't seem to figure out how a List stores info. Does it merely link to info

Yes using a TLINK.

can it actually store it.

No. A link is stored in the list.
Can I create a Local object, and add it to a list, and then have that object be destructed while retaining the info in the list?
Yes. The link will stop it from being Garbage collected.


TwoCorin517(Posted 2008) [#4]
So I can do something like:
Method AddSubSkill(NewSubSkillName:String, NewSubSkillValue:Int)
Local NewSubSkill:TSkill    'A Type that contains a value, and a Name.
NewSubSkill.Name = NewSubSkillName
NewSubSkill.Value = NewSubSkillValue
ListAddLast SubSkills, NewSubSkill
End Method

And that would work?


Perturbatio(Posted 2008) [#5]
yerp


Czar Flavius(Posted 2008) [#6]
have that object be destructed while retaining the info in the list
Think about this carefully and you'll see the two are mutually exclusive.