/*
 * Marc Groenewegen, 2023
 */

#include <iostream>
#include <set>
#include <iterator>


int main()
{
// multiset can contain duplicates, an ordinary set can not!
std::multiset<std::string> myset;
std::multiset<std::string>::iterator pos;

  myset.insert("joepie");
  myset.insert("dit");
  myset.insert("programmeerwerk");
  myset.insert("is");
  myset.insert("leuk");
  myset.insert("wel");
  myset.insert("leuk");
  myset.insert("dit");

  std::cout << "Size: " << myset.size() << std::endl;

  std::cout << std::endl << "Set's contents: " << std::endl;
  pos=myset.begin();
  while(pos != myset.end())
  {
    std::cout << *pos << std::endl;
    pos++;
  }
  std::cout << std::endl;

  std::string word2find = "leuk";
  pos = myset.find(word2find);


  if(pos == myset.end()){
    std::cout << word2find << " not found" << std::endl;
  }
  else {
    std::cout << "Found \"" << word2find << "\"" << std::endl;
    myset.insert(pos,"ook");

    std::cout << std::endl << "Set's contents: " << std::endl;
    pos=myset.begin();
    while(pos != myset.end())
    {
      std::cout << *pos << std::endl;
      pos++;
    }
    std::cout << std::endl;
  } // else

  return 0;
}
