• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM What makes ds_lists, ds_maps, and ds_grids different from an array?

O

Olivebates

Guest
Hello,

For someone who has adhd, and can't read long texts (like the manual), what's the difference in perks between ds_lists, ds_maps, ds_grids, and arrays? When would you use one over the other?

Thanks in advance <3
 
Last edited by a moderator:

Mick

Member
I think you should read the manual about the data structures, it wont take long. ds_lists can be compared to arrays but the other data structures are different.
 

NightFrost

Member
I'd say most importantly, GMS has such a limited set of commands for manipulating arrays that if you want to do anything complex with your data structures, ds_* commands are your go-to choice. Also, ds_* commands are reportedly slightly faster than arrays, but that comes into play only if you make a large amount of calls to your data every step.
 

TheouAegis

Member
A ds_list is a fancy 1D array that can be easily resized, values can be added at any position, and the order can easily be either sorted or randomized.
A ds_stack is a fancy 1D array that can be easily resized with limited capacity and is read from in the reverse order that it's written to.
A ds_queue is a fancy 1D array that can be easily resized with limited capacity and is read from in the same order that it's written to.
A ds_priority_queue is a fancy 1D array that can be easily resized with limited capacity and is automatically ordered based on the weight of each value.
A ds_map is a fancy 1D array that can be easily resized and each index can be either a string or real. Great for people that can't differentiate between strings and reals. :rolleyes: Can also be encrypted.
A ds_grid is a fancy 2D array that can be easily resized, ranges of values can be set at once, arithmetic operations can be performed on regions, min/max values of regions can be easily calculated, and can easily be randomized or sorted.
 
O

Olivebates

Guest
A ds_list is a fancy 1D array that can be easily resized, values can be added at any position, and the order can easily be either sorted or randomized.
A ds_stack is a fancy 1D array that can be easily resized with limited capacity and is read from in the reverse order that it's written to.
A ds_queue is a fancy 1D array that can be easily resized with limited capacity and is read from in the same order that it's written to.
A ds_priority_queue is a fancy 1D array that can be easily resized with limited capacity and is automatically ordered based on the weight of each value.
A ds_map is a fancy 1D array that can be easily resized and each index can be either a string or real. Great for people that can't differentiate between strings and reals. :rolleyes: Can also be encrypted.
A ds_grid is a fancy 2D array that can be easily resized, ranges of values can be set at once, arithmetic operations can be performed on regions, min/max values of regions can be easily calculated, and can easily be randomized or sorted.
Thanks, this is exactly what I was looking for! <3
 

Jobo

Member
GMC Elder
I feel TheouAegis' response is a bit misleading and doesn't do well to explain what each type is used for.

ds_list is a sequential list data structure.
You add to, insert in and remove from the list - it's always sequential, and you can iterate over it easily by going from index 0 to index n-1 where n is the length of the list. Perfect for iteration.

ds_stack is a top down stack data structure.
You push onto the stack, and you pop off the stack. You only manipulate the value at the top of the stack. You can also "peek" at the stack to get the top value without removing it from the stack. You can't iterate over the stack without changing its state (it would be empty when you're done).

ds_map is a key-value dictionary data structure.
You map a key to a value. You can e.g. map the key "player_name" to the value "Olivebates", or the number 1 to the value "One". It is not sequential; it's an associative array - like a table, basically. You use a map to "look up" a value, e.g. "player_name".

ds_grid is a grid-based data structure.
You have a grid of cells, and each cell can be given a value. It is a plain 2-dimensional array - but a neat way to handle it. Iterating over this requires 2 loops, one for rows and one for columns on each row.

ds_queue and ds_priority_queue are rarely used in my experience. In fact, I have never used them myself.
 
O

Olivebates

Guest
Yes, even better.I get it now. Theo mentioned they have limited space. If I for any reason exceed this limit, well it crash, overwrite a previous entry, or just ignore it?
Thanks!
 
O

Olivebates

Guest
Haha alright. I'll save a copy of your explination for future reference. Thanks a billion, friendo! <3~
 

TheouAegis

Member
"limited capacity" doesn't mean limited space, it means you can easily resize them one line at a time. A grid can be resized by multiple rows/columns, though.

Also a ds_grid is a rectangular 2D array, whereas a 2D array is not a quadrilateral.
 
Top