list::remove (STL/CLR)
移除具有指定值的項目。
void remove(value_type val);
參數
- val
若要移除之項目的值。
備註
成員函式移除受控制序列中項目,其((System::Object^)val)->Equals((System::Object^)x)為 true (如果有的話)。 您可以用它來清除指定的值與任意項目。
範例
// 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);
}
需求
標頭: < cliext/清單 >
Namespace: cliext