Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. template <typename TKey, typename TValue>
  2. struct resetter : public std::unary_function<std::pair<TKey, TValue> > {
  3. TValue const value;
  4.  
  5. public resetter(value const& v) : value(v) { }
  6.  
  7. public void operator ()(std::pair<TKey, TValue>& v) {
  8. v.second = value;
  9. }
  10. };
  11.  
  12. for_each(map.begin(), map.end(), resetter<Key, Value>(value));
  13.  
  14. map <int,string> myMap;
  15. for( int k=0;k<1000;k++)
  16. myMap.insert(pair<int,string>(k,string("")));
  17.  
  18. map<string,int> m;
  19. insert( m )( "Bar", 1 )( "Foo", 2 );
  20.  
  21. map<int,int> next = map_list_of(1,2)(2,3)(3,4)(4,5)(5,6);
  22.  
  23. pair<int,string> init( 0,string(""));
  24. multimap <int,string> myMap = repeat(1000,init);
  25.  
  26. map <int,string> myMap;
  27.  
  28. struct nextkey
  29. {
  30. int start;
  31. nextkey( s ) : start( s ) {}
  32. pair<int,string> operator () ()
  33. {
  34. return pair<int,string>(start++,string(""));
  35. }
  36. };
  37.  
  38. myMap = repeat_fun(1000,nextkey(0));
  39.  
  40. map <int,string> myMap;
  41. for( int k=0;k<1000;k++)
  42. myMap.insert(pair<int,string>(k,string("")));
  43.  
  44. #include <boost/range/adaptor/map.hpp>
  45. auto my_values = boost::adaptors::values(my_map);
  46. std::fill(my_values.begin(), my_values.end(), 123);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement