Count: Difference between revisions
Jump to navigation
Jump to search
imported>Heeheehee Created page with example. |
imported>Heeheehee m Logic fix. |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
FunctionPage| | FunctionPage| | ||
name={{#var:name}}| | name={{#var:name}}| | ||
function1={{Function| | function1={{Function| | ||
Line 22: | Line 21: | ||
code= | code= | ||
<syntaxhighlight> | <syntaxhighlight> | ||
item [int] | item [int] map; | ||
boolean newkey(item i) { | boolean newkey(item i) { | ||
map[count(map | map[count(map)] = i; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}}| | }}| | ||
see_also={{SeeAlso|file_to_map| | see_also={{SeeAlso|clear|file_to_map|map_to_file}}| | ||
special=This function returns 0 for an empty map (i.e. with 0 keys). | special=This function returns 0 for an empty map (i.e. with 0 keys). | ||
}} | }} | ||
[[Category:Miscellaneous Functions]] |
Latest revision as of 03:50, 7 July 2010
Function Syntax
Returns the number of keys in the specified aggregate.
Code Samples
This example function uses count to create a new key in a map (defined outside the function to hopefully eliminate some confusion).
item [int] map;
boolean newkey(item i) {
map[count(map)] = i;
}
See Also
Special
This function returns 0 for an empty map (i.e. with 0 keys).