dynamically allocated structures : what would you recommand?

Started by Monsieur OUXX, Sun 01/07/2007 16:13:01

Previous topic - Next topic

Monsieur OUXX

I'm trying do find the best possible dynamic structure among all possible dynamic structures in AGS script.

For example, a String is a dynamic structure : you can resize it in memory with an "Append" operation. Heir of Norton understood that and exploited this workaround to use Strings as dynamic arrays in his "Vector" module.

But, what other dynamic structures are available?

I've thought of dynamic sprites, but i don't know if there is a per-pixel access, and if so, i don't know if it's awfully slow or not.

I've also thought of declaring a basic array (myArray[1000000000000000];  ;) ), and use it as if it was the RAM. Then i'd write some allocation routines (malloc, delete...).

Another solution : GUI objects such as ListBox; one can add up to 200 rows to a ListBox, AND, most important, pointers to ListBoxes are available. But there may be a limit to the number of declared ListBoxes...




PS : (about arrays) : read this thread
 

GarageGothic

I think Strings are definitely the way to go. Pixel data cannot be read back without SSH's very hackish ReadBMP Module which is pretty slow. And as you yourself noted in the other thread, declaring a large array will bloat the file size and take up memory space even when it's empty.

If it's for a public module, I don't recommend using list boxes. The chance of conflicts with existing GUIs is large, and as you say, there are limits for the number of GUI objects.

Monsieur OUXX

Quote from: GarageGothic on Mon 02/07/2007 16:38:51
- I think Strings are definitely the way to go
- declaring a large array will bloat the file size

Anyway, i think that int[] may be the best solution because i don't need a large amount of memory and the acces to a typed ("int[]", "float[]") built-in array is probably much much much faster than the conversions required by the "String workaround".

 

SMF spam blocked by CleanTalk