ds_map_find_next

Finds and returns the next key in the ds_map after the one specified in the function.

Syntax:

GML Code Example

ds_map_find_next(id, key);


Argument Description
id The id of the map to use.
key The key to find the next one to.


Returns: Real, string or undefined


Description

This function returns the next key stored in the ds_map after the one specified in the function. 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. If no such key exists then the function will return <undefined>. You should always check this using the is_undefined() function.



Example:

GML Code Example

var size, key, i;
 size = ds_map_size(inventory);
 key = ds_map_find_first(inventory);
 for (i = 0; i < size; i++;)
    {
    if first != "gold" first = ds_map_find_next(inventory, first) 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.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here