memory - Does a ds_map destroy sub-maps? -


i trying make lighting system in game maker , structure system want contain of lights in ds_map. want ds_map held inside second ds_map contains of lights in system

lights { "l-01": {"x":20, "y":40, "radius":15}, ... } 

the question have regards cleaning system: have iterate through map destroying of sub-maps , destroy map, game maker automatically destroy sub-maps when light map gets destroyed?

ds_map_destroy(lights); // sub maps ("l-01") destroyed? 

or have this:

var k = ds_map_find_first(lights); repeat(ds_map_size(lights)){     ds_map_destroy(lights[? k]);     k = ds_map_find_next(lights, k); } 

following along first question, if delete key game maker destroy sub-map

ds_map_delete(lights, "l-01") // destroy map indexed under "l-01" 

you may ask: "why using ds_map hold bunch of ds_maps, why not create list of maps?

answer comes second question. if held maps in list, , need delete 1 of maps list resize on removal of map, therefore offsetting of other indexed values second reason in game maker, ds_maps quicker ds_lists

i hope have made question clear , 1 of out there has answer.

if marked added data structure list/map (using ds_list_mark_as_map() or ds_list_mark_as_list) deleted automatically. otherwise need delete yourself.

from documentation ds_list_mark_as_list():

this function "mark" (or "flag") given position within created ds_list holding ds_list. functionality designed use when encoding json strings (which can create using json_encode) , complimentary ds map functions.

note: once ds_list has had value within flagged list or map, destroying list destroy marked lists , maps too. means not have manually go through list contents , destroy marked data structures individually before destroying "parent" list.

if have doubts can check, data structure exists or not, using ds_exists()


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -