ds_map_mirror

Downloadds_map_mirror(dsid)   Swaps the keys and values of the given ds_map data structure.
/*
**  Usage:
**      ds_map_mirror(dsid)
**
**  Arguments:
**      dsid        ds_map data structure for which
**                  keys and values will be swapped
**
**  Returns:
**      nothing
**
**  GMLscripts.com
*/

{
    var dsid,temp,key,val;
    dsid = argument0;
    temp = ds_map_create();
    key = ds_map_find_first(dsid);
    val = ds_map_find_value(dsid,key);
    ds_map_add(temp,val,key);
    repeat (ds_map_size(dsid)-1) {
        key = ds_map_find_next(dsid,key);
        val = ds_map_find_value(dsid,key);
        ds_map_add(temp,val,key);
    }
    ds_map_copy(dsid,temp);
    ds_map_destroy(temp);
}

Click if you've used this script[Please Login]
Projects: 4

 Contributor: Leif902


comments powered by Disqus