// test_set.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <set>
#include <iostream>
template <typename Container>
void PrintContents(const Container &stlContainer);
int main()
{
using namespace std;
set <int> setIntegers;
multiset <int> msetIntegers;
setIntegers.insert(1);
setIntegers.insert(4);
setIntegers.insert(7);
cout<<"writing the contents of the set to the screen"<< endl;
PrintContents(setIntegers);
msetIntegers.insert(setIntegers.begin(),setIntegers.end());
msetIntegers.insert(3000);
msetIntegers.insert(3000);
msetIntegers.insert(3000);
cout<<"Writing the contents of the multiset to the screen"<<endl;
PrintContents(msetIntegers);
cout<<"Number of instance of '3000' in the multiset are:";
cout<<msetIntegers.count(3000)<<endl;
getchar();
return 0;
}
template <typename Container>
void PrintContents(const Container &stlContainer)
{
Container::const_iterator iElementLocator = stlContainer.begin();
while(iElementLocator != stlContainer.end())
{
std::cout<<*iElementLocator<<std::endl;
iElementLocator++;
}
std::cout<<std::endl;
}