Skip to content

Instantly share code, notes, and snippets.

@xaxxon
Created February 5, 2016 19:27
Show Gist options
  • Save xaxxon/8dcad98c338bf0961470 to your computer and use it in GitHub Desktop.
Save xaxxon/8dcad98c338bf0961470 to your computer and use it in GitHub Desktop.
#include <vector>
#include <unordered_set>
#include <stdlib.h>
int random(int max){
return rand() % max;
}
#define SIZE 1000000
int main()
{
srand(1000);
std::vector<int> v(SIZE, 5);
for(int i = 0; i < 10000000; i++) {
v.erase(v.begin() + random(SIZE));
if(i%10000==0){printf("%d\n",i);}
//v.erase(v.begin());
v.push_back(5);
}
exit(0);
std::unordered_set<int> s;
for (int i = 0; i < SIZE; i++) {
s.insert(i);
}
int value;
fprintf(stderr, "Starting\n");
for(int i = 0; i < 10000000; i++) {
if(i%10000==0){printf("%d\n",i);}
value = random(SIZE);
s.erase(value);
s.insert(value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment