remove

Syntax:

    #include <list>
    void remove( const TYPE &val );

The function remove() removes all elements that are equal to val from the list. For example, the following code creates a list of the first 10 characters of the alphabet, then uses remove() to remove the letter 'E' from the list:

     // Create a list that has the first 10 letters of the alphabet
     list<char> charList;
     for( int i=0; i < 10; i++ )
       charList.push_front( i + 65 );
     // Remove all instances of 'E'
     charList.remove( 'E' );

Remove runs in linear time.

Related Topics: erase, remove_if, unique