HomeManualTopicsTypesSymbols

std::count

counts items in a collection

Parameters

collection
test (default: NONE)
argument (default: NONE)

Results

None

Description

Returns the number of items in the specified collection that fullfill the specified criterion.

If no test-function is given the collection must contain boolean values.

If an argument is given the test-function is called with the collection item as the first argument and the argument as the second argument.

Example

$persons hash_table "Gregory" = 39 "Julia" = 37 "Maria" = 33 "James" = 41 "Sarah" = 38 println! count(persons less 40)

Output

4

Topic

Collections

See also

std::any_of tests all items of a collection
std::all_of tests all items of a collection