Native/C++

list

aucd29 2013. 10. 2. 19:03
[code]list <entry> phone_book;
void print_entry(const string& s)
{
    typedef list<entry> ::const_iterator LI;
    LI i;
    for (i = phone_book.begin(); i!=phone_book.end(); ++i)
    {
        const entry& e = *i;
        if (s == e.name)
        {
            cout << e.name << ' ' << e.number << endl;
            return;
        }
    }
}

void f(const entry& e, list<entry>::iterator i, list<entry>::iterator p)
{
    phone_book.push_front(e);
    phone_book.push_back(e);
    phone_book.insert(i, e);    // i 에 의해 참조되는 원소앞에 삽입
    phone_book.erase(p);        // p 에 의해 참조되는 원소 지움
}[/code]