code_junkie

Existence map in C++

Nov 11th, 2011
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. D:Temp>type vectorbool.cpp
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. vector<bool> vb(10);
  9. vb[5] = true;
  10.  
  11. for (vector<bool>::const_iterator ci = vb.begin(); ci != vb.end(); ++ci) {
  12. cout << *ci << endl;
  13. }
  14. }
  15.  
  16. D:Temp>cl /nologo /W4 /EHsc vectorbool.cpp
  17. vectorbool.cpp
  18.  
  19. D:Temp>vectorbool.exe
  20. 0
  21. 0
  22. 0
  23. 0
  24. 0
  25. 1
  26. 0
  27. 0
  28. 0
  29. 0
  30.  
  31. if (mapObj.count(item) != 0)
  32. {
  33. // item exists
  34. }
Add Comment
Please, Sign In to add comment