ds_map_find_first


描述

This function returns the first key stored in the ds_map. This is not the first key in the order you added them! Ds_maps are not stored in a linear form, for that use ds_lists, so all this does is find the first key as stored by the computer. This can be useful if your have to iterate through the ds_map looking for something, but should be avoided if possible as it can be slow.


语法:

ds_map_find_first(id);

参数 描述
id The id of the map to use.


返回:

Real or String


例如:

var size = ds_map_size(inventory) ;
var key = ds_map_find_first(inventory);
for (var i = 0; i < size; i++;)
   {
   if key != "gold"
      {
      key = ds_map_find_next(inventory, key);
      }
   else break;
   }

The above code creates some temporary variables and then gets the ds_map size and finds the first key as stored by the computer in the map. It then uses a for loop to iterate through the ds_map looking for the key value "gold". If it finds it, it breaks out the loop.