Difference between revisions of "Clear"
Jump to navigation
Jump to search
imported>StDoodle (Created page with '{{ #vardefine:name|clear}}{{ #vardefine:return_type|void}}{{ FunctionPage| name={{#var:name}}| function_category=Miscellaneous| function1={{Function| name={{#var:name}}| aggreg…') |
imported>Eliteofdelete |
||
(One intermediate revision by one other user not shown) | |||
Line 5: | Line 5: | ||
FunctionPage| | FunctionPage| | ||
name={{#var:name}}| | name={{#var:name}}| | ||
− | |||
function1={{Function| | function1={{Function| | ||
Line 18: | Line 17: | ||
function_description=Clears the aggregate {{pspan|map}} of all its keys & data.| | function_description=Clears the aggregate {{pspan|map}} of all its keys & data.| | ||
− | + | code1={{CodeSample| | |
+ | title=Code Samples| | ||
+ | description=Tells you how many different items you have and then clears the map.| | ||
+ | code= | ||
+ | <syntaxhighlight> | ||
+ | int[item] inventory = get_inventory(); | ||
+ | print("You currently have "+count(inventory)+" different items in your inventory.", "blue"); | ||
+ | clear(inventory); | ||
+ | print("Now there are "+count(inventory)+" different items in the inventory map.", "blue"); | ||
+ | </syntaxhighlight>| | ||
+ | moreinfo= | ||
+ | The clear command is most often used when doing lots of map manipulation, since maps only grow in size when assigning values to them. | ||
+ | }}| | ||
see_also={{SeeAlso|count|file_to_map|map_to_file}}| | see_also={{SeeAlso|count|file_to_map|map_to_file}}| | ||
}} | }} | ||
+ | |||
+ | [[Category:Miscellaneous Functions]] |
Latest revision as of 08:25, 11 January 2015
Function Syntax
- map is the aggregate to clear
Clears the aggregate map of all its keys & data.
Code Samples
Tells you how many different items you have and then clears the map.
int[item] inventory = get_inventory();
print("You currently have "+count(inventory)+" different items in your inventory.", "blue");
clear(inventory);
print("Now there are "+count(inventory)+" different items in the inventory map.", "blue");
The clear command is most often used when doing lots of map manipulation, since maps only grow in size when assigning values to them.