// File: hash_map2.cpp // // Simple use of hash_map container class // Note hash_map is not in C++ standard (yet???) // #include #include #include #include using namespace std ; const unsigned long int seed = 38913154 ; //const int reps = 10000 ; // ten thousand //const int reps = 20000 ; // twenty thousand //const int reps = 200000 ; // two *hundred* thousand const int reps = 400000 ; // four *hundred* thousand int main() { hash_map T ; int x, found = 0 ; srandom(seed) ; for (int i = 0 ; i < reps ; i++) { T[random()] = true ; } for (int i = 0 ; i < reps ; i++) { x = random() ; if (T.find(x) != T.end()) found++ ; } cout << "Number of random numbers found: " << found << "\n" ; }