#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void printV(vector<int> &v){
    for(int element: v){
        cout << element << " ";
    }
    cout << "\n";
}

int main(){
    //Popping from the back (last element) of a vector is very fast, this first loop runs in less then .1 second.
    vector<int> vec1(1000000,5);
    while(vec1.size()){
        vec1.pop_back();
    }
    cout << "DONE VEC1\n";

    //removing from the front (or in the middle) of a vector is very slow, everytime a value
    //gets removed the entire contents of the vector are shifted backwards
    //this is also why .insert() is slow.
    //this is the reason pop_front() is not a function in c++ and we have to instead use erase.
    vector<int> vec2(100000,5);

    while(vec2.size()){
        vec2.erase(vec2.begin());


    //Warning if you run this code and DONE VEC2 does print instantly it is because since nothing is actually
    //happening with the vector the compiler will FOR THIS TOY EXAMPLE be able to optimize away this mistake
    //of erasing from the beginning. This is only because this is a very very simple program that doesn't do anything
    //for any actual program the compiler likely can't make this severe of an optimization
    //several minutes to finish.
    cout << "DONE VEC2";
    return 0;
    }
}
