Advertisement
Guest User

Untitled

a guest
Dec 16th, 2013
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <map>
  2. #include <fstream>
  3. #include <string>
  4. #include <vector>
  5. #include <windows.h>
  6. #include <iostream>
  7.  
  8. int main()
  9. {
  10.     std::vector<std::string> List;
  11.     std::string line;
  12.     std::map<std::string, bool> Dict;
  13.  
  14.     DWORD TC = GetTickCount();
  15.  
  16.     std::ifstream input("test.txt");
  17.     while(!input.eof())
  18.     {
  19.         input >> line;
  20.         List.push_back(line);
  21.     }
  22.  
  23.     std::cout << "Reading file speed: " << GetTickCount() - TC << " ms." << std::endl;
  24.     TC = GetTickCount();
  25.  
  26.     for(int i = 0; i < List.size(); i++)
  27.     {
  28.         Dict[List[i]] = true;
  29.     }
  30.  
  31.     std::cout << "Adding to the dictionary: " << GetTickCount() - TC << " ms." << std::endl;
  32.     TC = GetTickCount();
  33.  
  34.     bool b = false;
  35.     for(int i = 0; i < List.size(); i++)
  36.     {
  37.         b = Dict[List[i]];
  38.         if(!b)
  39.             break;
  40.     }
  41.  
  42.     std::cout << "Dictionary reading: " << GetTickCount() - TC << " ms." << std::endl;
  43.     TC = GetTickCount();
  44.    
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement