Array or Tlist ??

BlitzMax Forums/BlitzMax Beginners Area/Array or Tlist ??

Blitzplotter(Posted 2006) [#1]
Hi folks. I've some experience of B3D, managed to suss how to populate 10 strings with variable user input - Howvever I'm only just getting to grips with BMax. Would it be best to use a Tlist or an array for indivdual character manipulation within BMax ?


Grisu(Posted 2006) [#2]
In general the same rules for b3d apply in bmx.

A static array will always be faster than a Tlist.
Also you can easier access elements of a static array than those of a type list.

If you have a limited number of elements (10 in your case) I would mostly prefer a static array. But it really doesn't matter with modern pc's.

If you have lets say 1.000 or more elements it does!


Blitzplotter(Posted 2006) [#3]
Cheers Grisu - static array it is then...


bradford6(Posted 2006) [#4]
I think a dynamic array would be better. (no real difference)

this one resizes each time you press enter...

kind of a mess. code wise. got carried away.




Grey Alien(Posted 2006) [#5]
I tried to post this last night with an explanation but the site was down:

Strict
Local me$ = "hello"

Print Chr(me[4]) 'prints o (string is a zero-based array)

Local array$[3]

array[2] = "Jake"

Print Chr(array[2][0]) 'prints J
Print Chr(array[2][1]) 'prints A

Local List:TList = New TList
List.AddLast("one")
Print Chr(String(List.Last())[1]) 'prints n



Blitzplotter(Posted 2006) [#6]
Cheers guys,this was proving a stumbling block...

@ bradford6 your Case statements LOL :-}

@ Grey - I'll creep my revised project those baby steps forward again. Cheers - My motivation for re-doing a whole project that was so near to just needing bells and whistles (but was potentially fundamentally flawed in B3D) in a new programming language requires more dedication than I'd anticipated.... Rome wasn't built in a day.....


Blitzplotter(Posted 2006) [#7]
Just ran both your pieces of code -- very helpful with rapidly progressing individual character access within a string / array.


FlameDuck(Posted 2006) [#8]
A static array will always be faster than a Tlist.
That depends on what operations you're using them for.


Blitzplotter(Posted 2006) [#9]
My static array is being populated with user input strings which will stay static without any further modification once populated. Is Tlist a better option ... ?


Grey Alien(Posted 2006) [#10]
requires more dedication than I'd anticipated
Yeah, the whole reason I made a game framrwork is I was commisioned to do a match-3 game using my BlitzPlus engine but early on in discussions the producer wanted some fancy 3D card style effects and I knew I'd have to port to Max. I thought it might take a little while, but when I got really into it and found all this mini problems and things that needed fixing (in BMax (they are fixed now mostly)) and lots of oddities about the language the project suddenly was going to take MUCH longer. But I was determined to make something reuseable, hense the framework, so my next game (after the match-3) will be much quicker :-)


FlameDuck(Posted 2006) [#11]
My static array is being populated with user input strings which will stay static without any further modification once populated. Is Tlist a better option ... ?
Probably not. A TMap might be though.


Blitzplotter(Posted 2006) [#12]
Hmmm... not had the joy of TMap as yet... all in good time.