remove [C++ Reference]
Keywords: stl,list,remove
Date: 2008-10-14T15:42:06-0700

[[remove]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## 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

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •