*** 容器set的使用

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

int main()
{
    set <string> st;
    
    st.insert("apple");
    st.insert("orange");
    st.insert("strawberry");
    st.insert("peach");
    st.insert("orange");
    st.insert("banana");
    
    for (set<string>::iterator i=st.begin(); i!=st.end(); i++)
    {
        cout << *i << endl;
    }
    
    cout << "==== after erase peach ====" << endl;
    st.erase("peach");
    
    for (set<string>::iterator i=st.begin(); i!=st.end(); i++)
    {
        cout << *i << endl;
    }
    
    return 0 ;
}

 

posted @ 2019-01-02 21:03  super行者  阅读(108)  评论(0编辑  收藏  举报