ClearMap()

Syntax

ClearMap(Map())
Description
Clears all the elements in the specified map and releases their memory. After this call the map is still usable, but is empty (i.e. there are no more elements in it).

Parameters

Map() The map to clear.

Return value

None.

Remarks

PureBasic will only free the memory for the elements. If you have been using the map for something such as storing handles of objects that you create directly with the OS, there is no way PureBasic (or any other language) can know what they are. Therefore, in cases such as that, you should go through the elements in the map and free the objects yourself.

Example

  NewMap Country.s()

  Country("FR") = "France"
  Country("US") = "United States"

  ; Proof that items have been added to the map
  MessageRequester("Information", "There are "+Str(MapSize(Country()))+" elements in the map")
 
  ; Clear the map and show that the map really is empty
  ClearMap(Country())
  MessageRequester("Information", "There are "+Str(MapSize(Country()))+" element in the map")

See Also

AddMapElement(), DeleteMapElement()

Supported OS

All

<- AddMapElement() - Map Index - CopyMap() ->