#include <vector>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <iterator>
void capacity_increase(){
std::vector<int> vec;
std::cout <<vec.size()<< std::endl;
std::cout <<vec.capacity()<< std::endl;
std::cout <<vec.max_size()<< std::endl;
vec.push_back(1000);
std::cout <<vec.size()<< std::endl;
std::cout <<vec.capacity()<< std::endl;
std::cout <<vec.max_size()<< std::endl;
vec.resize(100);
std::cout <<vec.size()<< std::endl;
std::cout <<vec.capacity()<< std::endl;
std::cout <<vec.max_size()<< std::endl;
//vec.insert(100);
vec.push_back(1000);
std::cout <<vec.size()<< std::endl;
std::cout <<vec.capacity()<< std::endl;
std::cout <<vec.max_size()<< std::endl;
vec.reserve(300);
std::cout <<vec.size()<< std::endl;
std::cout <<vec.capacity()<< std::endl;
std::cout <<vec.max_size()<< std::endl;
vec.shrink_to_fit();
std::cout <<vec.size()<< std::endl;
std::cout <<vec.capacity()<< std::endl;
std::cout <<vec.max_size()<< std::endl;
}
void delete_elem(){
std::vector<int> vec(20);
std::generate(vec.begin(),vec.end(),[]{return rand() % 10;});
std::copy(vec.begin(),vec.end(),std::ostream_iterator<int>(std::cout," "));
std::cout <<'\n';
int value = 5;
//just delete one elem
/* auto pos = std::find(vec.begin(),vec.end(),5);
if(pos != vec.end())
pos = vec.erase(pos);
for(;pos != vec.end(); pos++){
std::cout << *pos<<" ";
}
std::cout <<'\n';
*/
// method 1 std::remove_if
auto vec1 = vec;
vec1.erase(std::remove_if(vec1.begin(),vec1.end(),[=](auto t){return t == value;}),vec1.end());
std::copy(vec1.begin(),vec1.end(),std::ostream_iterator<int>(std::cout," "));
std::cout <<'\n';
// method 2 erase
for(auto first = vec.begin();first != vec.end();){
if(*first == value)
vec.erase(first);
else
first++;
}
std::copy(vec.begin(),vec.end(),std::ostream_iterator<int>(std::cout," "));
std::cout <<'\n';
}