You are currently viewing the GMLscripts.com static mirror. Forum access and script submissions are not available through this mirror.

Invert GMLscripts.com

ds_map_mirror

ds_map_mirror(id)
Exchanges map keys with map values.
COPY/// ds_map_mirror(id)
//
//  Exchanges map keys with map values.
//
//      id          map data structure, real
//
/// GMLscripts.com/license
{
    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);
    return 0;
}

Contributors: Leif902

GitHub: View · Commits · Blame · Raw