#include <map>
#include <algorithm>
#include "auto.h"
#include "string3.h"

using namespace std;

typedef map <String, automobile, less<String> >  MAP;
typedef MAP::iterator   	map_iter;
typedef MAP::value_type 	map_value_type;

void Print(const map_value_type& print_type)
{
   cout<<print_type.first<<"\t\t"<<print_type.second<<endl;
}
bool Bin_Pred(const map_value_type& MI1, const map_value_type& MI2)
{if (MI1==MI2)return true; else return false;}

void main()
{
   MAP M1, M2;

   automobile
   	A1("Mers","в600вк"),
		A2("Audi","м185мм"),
		A3("Ford","к719пм"),
		A4("Kia","ф270ав"),
		A5("Nissan","а923су");

   M1.insert(make_pair(String(A1.GetModel()), A1));
   M1.insert(make_pair(String(A2.GetModel()), A2));
   M1.insert(make_pair(String(A3.GetModel()), A3));
   M1.insert(make_pair(String(A4.GetModel()), A4));
   M1.insert(make_pair(String(A5.GetModel()), A5));

// Вывод контейнера М1
   cout << "Первый контейнер map:\n";
   for (map_iter I = M1.begin(); I != M1.end(); I++)
	 cout << (*I).first << "\t\t" << (*I).second;

   map_iter I1=M1.find("Mers");
   map_iter I2=M1.find("Kia");
   M2.insert(I2,I1);
   cout<<"Первый контейнер map:\n";
   for_each(M1.begin(),M1.end(),Print);
 	cout << "Второй контейнер map:\n";
   for_each(M2.begin(), M2.end(), Print);
//Lab#6
	map_iter FI;
   FI=search(M1.begin(),M1.end(),M2.begin(),M2.end());
   if(FI==M1.end())cout<<"M1 contein M2!!!\n";
   else cout<<"M1 don't contein M2!!!\n";

   FI=search(M1.begin(),M1.end(),M2.begin(),M2.end(),Bin_Pred);
   if(FI==M1.end())cout<<"M1 contein M2!!!\n";
   else cout<<"M1 don't contein M2!!!\n";
}
