#include <boost/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <iostream>
#include <string>
#include <map>
#include <utility>
#include <functional>
template <typename map_type>
void print(const map_type& this_map)
{
for (typename map_type::const_iterator it = this_map.begin(); it!= this_map.end(); ++it)
{
std::cout<<"/t"<<it->first<<"-->"<<it->second<<std::endl;
}
}
template <typename bimap_type>
void bimap_insert(bimap_type& this_bimap)
{
this_bimap.insert( typename bimap_type::value_type(1,"first") );
this_bimap.insert( typename bimap_type::value_type(2,"second") );
this_bimap.insert( typename bimap_type::value_type(1,"hello,first"));
this_bimap.insert( typename bimap_type::value_type(2,"hello,second") );
this_bimap.insert( typename bimap_type::value_type(3,"first") );
this_bimap.insert( typename bimap_type::value_type(4,"second") );
this_bimap.insert( typename bimap_type::value_type(4,"second") );
}
int main(int argc, char* argv[])
{
boost::bimap< boost::bimaps::multiset_of<int>, boost::bimaps::set_of<std::string> > multiset_set;
boost::bimap< boost::bimaps::multiset_of<int>, boost::bimaps::multiset_of<std::string> > multiset_multiset;
boost::bimap< boost::bimaps::set_of<int>, boost::bimaps::set_of<std::string> > set_set;
boost::bimap< boost::bimaps::set_of<int>, boost::bimaps::multiset_of<std::string> > set_multiset;
std::cout<<"left multiset right set:"<<std::endl;
bimap_insert(multiset_set);
std::cout<<" right view:"<<std::endl;
print(multiset_set.right);
std::cout<<" left view:"<<std::endl;
print(multiset_set.left);
std::cout<<std::endl<<"left multiset right multiset:"<<std::endl;
bimap_insert(multiset_multiset);
std::cout<<" right view:"<<std::endl;
print(multiset_multiset.right);
std::cout<<" left view:"<<std::endl;
print(multiset_multiset.left);
std::cout<<std::endl<<"left set right set:"<<std::endl;
bimap_insert(set_set);
std::cout<<" right view:"<<std::endl;
print(set_set.right);
std::cout<<" left view:"<<std::endl;
print(set_set.left);
std::cout<<std::endl<<"left set right multiset:"<<std::endl;
bimap_insert(set_multiset);
std::cout<<" right view:"<<std::endl;
print(set_multiset.right);
std::cout<<" left view:"<<std::endl;
print(set_multiset.left);
std::map<int, std::string> my_map;
my_map.insert(std::make_pair(1,"one"));
my_map.insert(std::make_pair(1,"yijunjun"));// no effect
std::cout<<my_map[1]<<std::endl;
}
#include <boost/bimap/multiset_of.hpp>
#include <iostream>
#include <string>
#include <map>
#include <utility>
#include <functional>
template <typename map_type>
void print(const map_type& this_map)
{
for (typename map_type::const_iterator it = this_map.begin(); it!= this_map.end(); ++it)
{
std::cout<<"/t"<<it->first<<"-->"<<it->second<<std::endl;
}
}
template <typename bimap_type>
void bimap_insert(bimap_type& this_bimap)
{
this_bimap.insert( typename bimap_type::value_type(1,"first") );
this_bimap.insert( typename bimap_type::value_type(2,"second") );
this_bimap.insert( typename bimap_type::value_type(1,"hello,first"));
this_bimap.insert( typename bimap_type::value_type(2,"hello,second") );
this_bimap.insert( typename bimap_type::value_type(3,"first") );
this_bimap.insert( typename bimap_type::value_type(4,"second") );
this_bimap.insert( typename bimap_type::value_type(4,"second") );
}
int main(int argc, char* argv[])
{
boost::bimap< boost::bimaps::multiset_of<int>, boost::bimaps::set_of<std::string> > multiset_set;
boost::bimap< boost::bimaps::multiset_of<int>, boost::bimaps::multiset_of<std::string> > multiset_multiset;
boost::bimap< boost::bimaps::set_of<int>, boost::bimaps::set_of<std::string> > set_set;
boost::bimap< boost::bimaps::set_of<int>, boost::bimaps::multiset_of<std::string> > set_multiset;
std::cout<<"left multiset right set:"<<std::endl;
bimap_insert(multiset_set);
std::cout<<" right view:"<<std::endl;
print(multiset_set.right);
std::cout<<" left view:"<<std::endl;
print(multiset_set.left);
std::cout<<std::endl<<"left multiset right multiset:"<<std::endl;
bimap_insert(multiset_multiset);
std::cout<<" right view:"<<std::endl;
print(multiset_multiset.right);
std::cout<<" left view:"<<std::endl;
print(multiset_multiset.left);
std::cout<<std::endl<<"left set right set:"<<std::endl;
bimap_insert(set_set);
std::cout<<" right view:"<<std::endl;
print(set_set.right);
std::cout<<" left view:"<<std::endl;
print(set_set.left);
std::cout<<std::endl<<"left set right multiset:"<<std::endl;
bimap_insert(set_multiset);
std::cout<<" right view:"<<std::endl;
print(set_multiset.right);
std::cout<<" left view:"<<std::endl;
print(set_multiset.left);
std::map<int, std::string> my_map;
my_map.insert(std::make_pair(1,"one"));
my_map.insert(std::make_pair(1,"yijunjun"));// no effect
std::cout<<my_map[1]<<std::endl;
}