/*
    Sets can store sortable elements, but only one copy of each element 
    http://www.cplusplus.com/reference/set/set/
*/

#include <set>                // set
#include <iostream>           // cin/cout
using namespace std;


int main()
{
    set<string> wordset;      // string has comparison < thus it can be used in a set.

    cout << "Please enter some words:";

    string s;
    while (cin >> s)
    {
        auto ret=wordset.insert(s);
        if (ret.second) cout << "The new element " << s << " was inserted." << endl;
                   else cout << "The new element " << s << " was not inserted, as it is already in the set." << endl;
    }

    // Modern for loop:
    cout << "Modern loop access:" << endl;
    cout << "Wordset contains " << wordset.size() << " elements: ";
    for(auto& value : wordset) {
        cout << value << " ";
    }
    cout << endl;

    return 0;
}
