, :
#include "stdafx.h"
#include <iostream>
#include <set>
int main()
{
//
typedef std::set<int> IntSet;
IntSet coll; //
// 1 6
/*- 1 */
coll.insert(3);
coll.insert(1);
coll.insert(5);
coll.insert(4);
coll.insert(1);
coll.insert(6);
coll.insert(2);
/*
* - . */
IntSet::const_iterator pos;
for (pos = coll.begin(); pos!= coll.end(); ++pos) std::cout<<*pos <<' ';
std::cout << std::endl;
}
, : #include <set>
, : typedef std::set<int> IntSet;
IntSet int. , < ( ). , .
insert(), :
coll.insert(3);
coll.insert(1);
. push_back() push_front() . , .
. 9.5. , ( ) , . ( ) , 1 .
. 9.5.
, . :
IntSet::const_iterator pos;
for (pos = coll.begin(); pos!= coll.end(); ++pos) std::cout << *pos <<' ';
, , . , , ++ () . ++ () (. 9.6).
. 9.6. pos
: 1 2 3 4 5 6
, ( ):
typedef std::multiset<int> IntSet;
, 1. , :
1 1 2 3 4 5 6