os_count |
Counts items in a container that match a value.
A helper algorithm for count()
. Returns the number of elements in the container c
that match value using operator==
.
#include <ospace/helper/helpalgo.h>
template< class Container, class T >
int os_count( const Container& c, const T& value )
#include <iostream>
#include <vector>
#include <ospace/helper.h>
int numbers[ 10 ] = { 1, 2, 4, 1, 2, 4, 1, 2, 4, 1 };
void
main()
{
vector< int > v( numbers, numbers + 10 );
int result = os_count( v, 1 );
cout << "Found " << result << " 1's.\n";
}
Found 4 1's.
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.