/* Lecture code 8.0
 *
 * Using the <functional> library to count small elements in a vector<int>.
 */

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <functional>
using namespace std;

const int NUM_INTS = 10000;

bool LessThan(int one, int two)
{
	return one < two;
}

int main()
{
	vector<int> myVector;
	for(int i = 0; i < NUM_INTS; i++)
		myVector.push_back(rand());

	cout << count_if(myVector.begin(), myVector.end(),
					bind2nd(ptr_fun(LessThan), 137)) << endl;
	/* NOTE: Could also use
	 * bind2nd(less<int>(), 137) - See the handout.
	 */

	return 0;
}