Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

list::remove (STL/CLR)

Removes an element with a specified value.

    void remove(value_type val);
val

Value of the element to remove.

The member function removes an element in the controlled sequence for which ((System::Object^)val)->Equals((System::Object^)x) is true (if any). You use it to erase an arbitrary element with the specified value.

// cliext_list_remove.cpp 
// compile with: /clr 
#include <cliext/list> 
 
int main() 
    { 
    cliext::list<wchar_t> c1; 
    c1.push_back(L'a'); 
    c1.push_back(L'b'); 
    c1.push_back(L'c'); 
 
// display initial contents " a b c" 
    for each (wchar_t elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// fail to remove and redisplay 
    c1.remove(L'A'); 
    for each (wchar_t elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
 
// remove and redisplay 
    c1.remove(L'b'); 
    for each (wchar_t elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
 a b c
 a b c
 a c

Header: <cliext/list>

Namespace: cliext

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.