SetType& prompt_set(std::string preface, std::string message = "  Enter element for s2") {
   static SetType s2;
   s2.clear();
   for (;;) {
     std::string e = ics::prompt_string(preface + message + "(QUIT to quit)");
     if (e == "QUIT")
       break;
     s2.insert(e);
   }
   return s2;
 }
void process_tile_log(const char* filename) 
{
	ifstream infile(filename);
	char line[1024];	

	SetType uniqueSet;
	RetType ret;
	int repeatHitCounter = 0;
	int totalCounter = 0;
	cout << "==========================\n";

	while ( infile.getline(line, 1024) )
	{
		char* ptr = line;
		for (; *ptr != 'm' && *ptr != '\0'; ptr++)
			;

		// cout << ptr << endl;

		if (*ptr) 
		{
			totalCounter++;

			ret = uniqueSet.insert( string(ptr) );
			if (!ret.second) 
			{
				repeatHitCounter++;
				cout << "ERROR\t" << ptr << endl;
			}
		}

		if (totalCounter >= 100) {
			break;
		}	// µ×ͼÍßƬÎÆÀí»º´æ×î¶à100¸ö£¡
	}
	float rate = totalCounter > 0 ? (repeatHitCounter*1.0f / totalCounter) : 0;
	cout << "repeat hit rate = " << rate << endl;
	cout << "total hit = " << totalCounter << "\t" << "repeat hit = " << repeatHitCounter << endl;
	cout << "==========================\n";

	infile.close();
	uniqueSet.clear();
}
  void process_commands(std::string preface) {
    for (;;) try {
      std::string command = menu_prompt(preface);

      if (command == "i") {
        std::string e = ics::prompt_string(preface+"  Enter element to add");
        std::cout << preface+"  insert = " << s.insert(e) << std::endl;
      }

      else if (command == "I") {
        SetType s2(prompt_set(preface));
        std::cout << "  insert = " << s.insert(s2.abegin(),s2.aend()) << std::endl;;
      }

      else if (command == "e") {
        std::string e = ics::prompt_string(preface+"  Enter element to erase");
        std::cout << preface+"  erase = " << s.erase(e) << std::endl;
      }

      else if (command == "E") {
        SetType s2(prompt_set(preface));
        std::cout << "  erase = " << s.erase(s2.abegin(),s2.aend()) << std::endl;;
      }

      else if (command == "x")
        s.clear();

      else if (command == "R") {
        SetType s2(prompt_set(preface));
        std::cout << "  retain = " << s.retain(s2.abegin(),s2.aend()) << std::endl;
      }

      else if (command == "=") {
        SetType s2(prompt_set(preface));
        s = s2;
        std::cout << "  s now = " << s << std::endl;
      }

      else if (command == "m")
        std::cout << preface+"  empty = " << s.empty();

      else if (command == "s")
        std::cout << preface+"  size = " << s.size() << std::endl;


      else if (command == "c") {
        std::string e = ics::prompt_string(preface+"  Enter element to erase");
        std::cout << preface+"  contains = " << s.contains(e) << std::endl;
      }

      else if (command == "C") {
        SetType s2(prompt_set(preface));
        std::cout << "  contains = " << s.contains(s2.abegin(),s2.aend()) << std::endl;
      }

      else if (command == "<")
        std::cout << preface+"  << = " << s.str() << std::endl;

      else if (command == "r") {
        std::cout << preface+"  s == s = " << (s == s) << std::endl;
        std::cout << preface+"  s != s = " << (s != s) << std::endl;
        std::cout << preface+"  s <= s = " << (s <= s) << std::endl;
        std::cout << preface+"  s <  s = " << (s <  s) << std::endl;
        std::cout << preface+"  s >  s = " << (s >  s) << std::endl;
        std::cout << preface+"  s >= s = " << (s >= s) << std::endl;

        SetType s2(prompt_set(preface));
        std::cout << preface+"  s = " << s << " ?? s2 = " << s2 << std::endl;
        std::cout << preface+"  s == s2 = " << (s == s2) << std::endl;
        std::cout << preface+"  s != s2 = " << (s != s2) << std::endl;
        std::cout << preface+"  s <= s2 = " << (s <= s2) << std::endl;
        std::cout << preface+"  s <  s2 = " << (s <  s2) << std::endl;
        std::cout << preface+"  s >  s2 = " << (s >  s2) << std::endl;
        std::cout << preface+"  s >= s2 = " << (s >= s2) << std::endl;
      }

      else if (command == "l") {
        std::ifstream in_set;
        ics::safe_open(in_set,preface+"  Enter file name to read", "load.txt");
        std::string e;
        while (getline(in_set,e))
          s.insert(e);
        in_set.close();
      }

      else if (command == "it")
        process_iterator_commands(s, "it:  "+preface);

      else if (command == "q")
        break;

      else
        std::cout << preface+"\""+command+"\" is unknown command" << std::endl;

    } catch (ics::IcsError& e) {
      std::cout << preface+"  " << e.what() << std::endl;
    }

  };