<<< Node copy constructor     Index     Types of linked lists >>>

12. The STL list class

  • The STL list class provides:

    • functions for insertion and removal of elements

    • facilities for iteration over the elements in forward and reverse order

  • Node manipulation is hidden from the user.

  • 
    #include <iostream>
    #include <list>
    using namespace std;
    int main ()
    {
         // Two ints with a value of 100:
        list< int > mylist( 2, 100 );
        mylist.push_front( 200 );
        mylist.push_front( 300 );
        mylist.push_back( 555 );
    
        cout << "mylist contains:";
        list<int>::iterator it;
        for ( it = mylist.begin(); it != mylist.end(); ++it )
        {
            cout << " " << *it;
        }
        cout << endl;
        return 0;
    }
    /* Program output:
    mylist contains: 300 200 100 100 555
    */
    
    
<<< Node copy constructor     Index     Types of linked lists >>>