//=============================================================================

#include <iostream>
#include <set>
#include <string>
using namespace std;

//-----------------------------------------------------------------------------

int main()
{
   cout << "FH2022_02\n\n";

   set<int> s{ 1,23,3,45,2,3,7,36, 3,3,3,3,7,7,36, 5 };
   cout << "Groesse: " << s.size() << '\n';
   for (auto it = cbegin(s); it != cend(s); ++it)
   {
      cout << *it << ',';
   }
   cout << '\n';

   s.insert(0);
   s.insert(36);
   s.insert(37);
   s.insert(3);
   s.insert(7);

   cout << "Groesse: " << s.size() << '\n';
   for (auto it = cbegin(s); it != cend(s); ++it)
   {
      cout << *it << ',';
   }
   cout << '\n';

   // Die spezielle Find Funktion
   // - Iterator
   //   1. contains Info (End-Iterator => nicht drin)
   //   2. Original-Element (weil es eben doch manchmal wichtig ist)
   //   3. Position
   auto fit = s.find(7);
   if (fit != cend(s))
   {
      cout << "Gefunden: " << *fit << '\n';
   }
   else
   {
      cout << "Nicht drin\n";
   }

   int count = 0;
   for (auto fit = s.find(36); count < 6 && fit != cend(s); ++fit, ++count)
   {
      cout << "-> " << *fit << '\n';
   }


   //----------------------------------------------

   struct SLComparator
   {
      bool operator()(const string& s1, const string& s2) const
      {
         return s1.length() < s2.length();
      }
   };

   set<string, SLComparator> ss{ "Tom", "Eva", "Marcel", "Karl", "Heinrich", "Maximilian", "Lars", "Ansger" };
   for (auto it = cbegin(ss); it != cend(ss); ++it)
   {
      cout << *it << ',';
   }
   cout << '\n';

   auto sfit = ss.find("Max");
   if (sfit != cend(ss))
   {
      cout << "Gefunden: " << *sfit << '\n';
   }
   else
   {
      cout << "Nicht drin\n";
   }
}
