GM: Data structures

From GMpedia.org Wiki

Jump to: navigation, search

Data structures is a feature that was introduced in Game Maker 6.0. As the name says, data structures are used to store data. Most of this data could also be stored in arrays (single or two-dimensional) to get the same result. The advantage of data structures is that they can be destroyed (they are removed from memory) and they are easy to manage with some Game Maker functions.

[edit] Types of data structures

  • stack: a data structure that handles data on a so-called LIFO (Last-In First-Out) basis. The last item that was added to the stack is the first to be removed from it again.
  • queue: a data structure that handles data on a FIFO (First-In First Out) basis. Or: the item that has been added first, will be removed first.
  • list: simply a list. Game Maker contains functions to add, delete, insert, sort and search items in the list. Very similar to single-dimensional arrays.
  • maps: a map stores a key with a value. You can easily find the value that a key holds.
  • priority queues: also some kind of list structure but here you can specify a priority for each item. Functions exist to find or delete items with high or low priority.
  • grids: in this kind of data structure, you can store values using 2 indices. This is e.g. very useful when you need to store positions of instances. Grids can be compared to twodimensional arrays.
Personal tools