multimap::insert (STL/CLR)

添加元素。

    iterator insert(value_type val);
    iterator insert(iterator where, value_type val);
    template<typename InIter>
        void insert(InIter first, InIter last);
    void insert(System::Collections::Generic::IEnumerable<value_type>^ right);

参数

  • 首先
    范围开头插入的。

  • last
    范围的末尾插入的。

  • right
    要插入的枚举。

  • val
    要插入的键值。

  • where
    在插入 (仅提示的容器)。

备注

每个成员该成员函数序列由剩余的操作数指定的插入。

第一个成员函数插入带值 val的元素,并返回指定新插入的元素的迭代器。使用该插入一个元素。

第二个成员函数插入带值 val的元素,使用 where 作为提示 (提高性能),并返回指定新插入的元素的迭代器。使用该插入可能是在元素周围您知道的一个元素。

第三个成员函数插入序列 [first,last)。将它与另一个序列或多个元素复制的插入零。

该序列由 right指定的第四个成员函数插入。使用到序列由枚举数描述的插入。

每个元素插入所用时间比例与元素数的对数在控件的序列。插入在能够的常量时发生,但是将在旁边指定某个元素的提示插入点。

示例

// cliext_multimap_insert.cpp 
// compile with: /clr 
#include <cliext/map> 
 
typedef cliext::multimap<wchar_t, int> Mymultimap; 
int main() 
    { 
    Mymultimap c1; 
    c1.insert(Mymultimap::make_value(L'a', 1)); 
    c1.insert(Mymultimap::make_value(L'b', 2)); 
    c1.insert(Mymultimap::make_value(L'c', 3)); 
 
// display contents " [a 1] [b 2] [c 3]" 
    for each (Mymultimap::value_type elem in c1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// insert a single value, unique and duplicate 
    Mymultimap::iterator it = 
        c1.insert(Mymultimap::make_value(L'x', 24)); 
    System::Console::WriteLine("insert([L'x' 24]) = [{0} {1}]", 
        it->first, it->second); 
 
    it = c1.insert(Mymultimap::make_value(L'b', 2)); 
    System::Console::WriteLine("insert([L'b' 2]) = [{0} {1}]", 
        it->first, it->second); 
 
    for each (Mymultimap::value_type elem in c1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// insert a single value with hint 
    it = c1.insert(c1.begin(), Mymultimap::make_value(L'y', 25)); 
    System::Console::WriteLine("insert(begin(), [L'y' 25]) = [{0} {1}]", 
        it->first, it->second); 
    for each (Mymultimap::value_type elem in c1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// insert an iterator range 
    Mymultimap c2; 
    it = c1.end(); 
    c2.insert(c1.begin(), --it); 
    for each (Mymultimap::value_type elem in c2) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// insert an enumeration 
    Mymultimap c3; 
    c3.insert(   // NOTE: cast is not needed 
        (System::Collections::Generic:: 
            IEnumerable<Mymultimap::value_type>^)%c1); 
    for each (Mymultimap::value_type elem in c3) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
  

要求

标题: <cliext/映射>

命名空间: cliext

请参见

参考

multimap (STL/CLR)