/*
Demonstration iterator and vector + SORT, INSERT, ERASE
Athor Dombrovsky I.V.
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
vector<int> v = {1, 3, 5, 7, 9, 10, 2, 8, 4, 6};
//*****************************************************************************************
for (size_t i = 0; i < v.size(); i++) // Demonstration vector
cout << v[i] << " ";
cout << endl;
//*****************************************************************************************
vector<int>::iterator it;
it = v.begin();
//*****************************************************************************************
for(size_t i = 0; i < v.size(); i++) // Demonstration iterator
cout << *it + i << " ";
cout << endl;
//*****************************************************************************************
for (vector<int>::iterator i = v.begin(); i < v.end(); i++) // SHOW
cout << *i << " ";
cout << endl;
//*****************************************************************************************
cout << "Show vector" << endl;
for (vector<int>::reverse_iterator i = v.rbegin(); i < v.rend(); i++) // SHOW REVERSE
cout << *i << " ";
cout << endl;
//*****************************************************************************************
cout << "revers vector" << endl;
for (vector<int>::const_iterator i = v.begin(); i < v.end(); i++) // const iterator
cout << *i << " ";
cout << endl;
//*****************************************************************************************
vector<int>::iterator i = v.begin();
advance(i, 3);
cout << *i << endl;
v.insert(i, 88); // INSERT ELMENT 88
cout << "Insert show vector" << endl;
for (vector<int>::reverse_iterator i = v.rbegin(); i < v.rend(); i++) // SHOW REVERSE
cout << *i << " ";
cout << endl;
//*****************************************************************************************
vector<int>::iterator iErase = v.begin();
v.erase(iErase, iErase + 4); // DELETE WITH BEGIN END
cout << "Erase show vector" << endl;
for (vector<int>::iterator i = v.begin(); i < v.end(); i++) // SHOW
cout << *i << " ";
cout << endl;
//*****************************************************************************************
vector<double> v1 = {2.5, 4.58, 0.005, 78, 69, 0.123, 78.47, 47, 89, 12};
sort(v1.begin(), v1.end());
cout << "Sort show vector" << endl;
for (vector<double>::iterator i = v1.begin(); i < v1.end(); i++) // SHOW
cout << *i << " ";
cout << endl;
for (vector<double>::reverse_iterator i = v1.rbegin(); i < v1.rend(); i++) // SHOW REVERSE
cout << *i << " ";
cout << endl;
cout << endl;
system("pause");
return 0;
}