Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include<iostream>
  2. #include"hash_map.h"
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     HashMap<int,int> petr{};
  8.     petr[3] = 5;
  9.     petr[2] = 1;
  10.     petr[0] = 7;
  11.     petr.print();
  12.     auto it = petr.find(0);
  13.     if (it != petr.end()) {
  14.         cout << it->second<< "\n" ;
  15.     } else {
  16.         cout << -1 << "\n";
  17.     }
  18.     petr.erase(0);
  19.    
  20.     petr.print();
  21.    
  22.     cout << petr[0] << "\n";
  23.    
  24.     cout << petr.Table[0].first->first << " " << petr.Table[0].first->second;
  25.     /*auto it1 = petr.find(0);
  26.     if (it != petr.end()) {
  27.         cout << it->second << "\n";
  28.     } else {
  29.         cout << -1 << "\n";
  30.     }
  31.    
  32.     auto it2 = petr.find(2);
  33.     if (it != petr.end()) {
  34.         cout << it->second << "\n";
  35.     } else {
  36.         cout << -1 << "\n";
  37.     }
  38.    
  39.     petr[8] = -4;
  40.    
  41.     for (auto i = petr.begin(); i!=petr.end(); ++i){
  42.         cout << i->first << " " << i->second << "\n";
  43.     }
  44.     petr.clear();
  45.    
  46.     auto it3 = petr.find(3);
  47.     if (it != petr.end()) {
  48.         cout << it->second << "\n";
  49.     } else {
  50.         cout << -1 << "\n";
  51.     }
  52.    
  53.     petr[3] = 5;
  54.    
  55.     auto it4 = petr.find(3);
  56.     if (it != petr.end()) {
  57.         cout << it->second << "\n";
  58.     } else {
  59.         cout << -1 << "\n";
  60.     }*/
  61.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement