Created
February 5, 2016 19:27
-
-
Save xaxxon/8dcad98c338bf0961470 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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