hash_multiset::erase (STL/CLR)

移除指定位置处的元素。

    iterator erase(iterator where);
    iterator erase(iterator first, iterator last);
    bool erase(key_type key)

参数

  • 首先
    清除的范围开头。


  • 清除的键值。

  • last
    清除的范围末尾。

  • where
    清除的元素。

备注

第一移除成员函数控制序列的元素由 where指向,并返回指定保持了元素外的第一个元素。移除的迭代器,或者 hash_multiset::end (STL/CLR)(),如果不存在这样的元素。 使用它将删除一个元素。

第二个成员中移除函数控制元素在序列的范围的 [first, last),并返回指定保持超过所有元素外的第一个元素。移除的迭代器,或 end(),如果不存在这样的元素。 您移除它使用零个或更多连续的元素。

第三个成员函数移除键有等效排序到 key控件序列的所有元素,并返回元素的数目的计数中移除。 使用它、移除和计数与指定键的所有元素。

每个元素抹除需要时间比例。元素数为底的对数控制在序列中。

示例

// cliext_hash_multiset_erase.cpp 
// compile with: /clr 
#include <cliext/hash_set> 
 
typedef cliext::hash_multiset<wchar_t> Myhash_multiset; 
int main() 
    { 
    Myhash_multiset c1; 
    c1.insert(L'a'); 
    c1.insert(L'b'); 
    c1.insert(L'c'); 
 
// display initial contents " a b c" 
    for each (wchar_t elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// erase an element and reinspect 
    System::Console::WriteLine("erase(begin()) = {0}", 
        *c1.erase(c1.begin())); 
 
// add elements and display " b c d e" 
    c1.insert(L'd'); 
    c1.insert(L'e'); 
    for each (wchar_t elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// erase all but end 
    Myhash_multiset::iterator it = c1.end(); 
    System::Console::WriteLine("erase(begin(), end()-1) = {0}", 
        *c1.erase(c1.begin(), --it)); 
    System::Console::WriteLine("size() = {0}", c1.size()); 
    return (0); 
    } 
 
  

要求

页眉: <cliext/hash_set>

命名空间: cliext

请参见

参考

hash_multiset (STL/CLR)

hash_multiset::clear (STL/CLR)