map::map (STL/CLR)

构造容器对象。

    map();
    explicit map(key_compare^ pred);
    map(map<Key, Mapped>% right);
    map(map<Key, Mapped>^ right);
    template<typename InIter>
        mapmap(InIter first, InIter last);
    template<typename InIter>
        map(InIter first, InIter last,
            key_compare^ pred);
    map(System::Collections::Generic::IEnumerable<GValue>^ right);
    map(System::Collections::Generic::IEnumerable<GValue>^ right,
        key_compare^ pred);

参数

  • 首先
    范围开头插入的。

  • last
    范围的末尾插入的。

  • pred
    控件序列的排序的性质。

  • right
    对象或范围插入。

备注

构造函数:

map();

初始化控件序列没有元素,其默认值为排序的谓词 key_compare()。使用它指定空的初始控件序列,其默认值为排序的性质。

构造函数:

explicit map(key_compare^ pred);

初始化控件序列没有元素,与排序的谓词 pred。使用它指定空的初始控件序列,与指定的排序的性质。

构造函数:

map(map<Key, Mapped>% right);

初始化该序列 [right.map::begin (STL/CLR)(),right.与默认的排序谓词的map::end (STL/CLR)())的控件,序列。将它指定为的副本顺序来按映射对象 right的初始控件序列,其默认值为排序的性质。

构造函数:

map(map<Key, Mapped>^ right);

初始化该序列 [right->map::begin (STL/CLR)(),right->与默认的排序谓词的map::end (STL/CLR)())的控件,序列。将它指定为的副本顺序来按映射对象 right的初始控件序列,其默认值为排序的性质。

构造函数:

template<typename InIter>

map(InIter first, InIter last);

初始化该序列 [first,与默认的排序谓词的last)的控件,序列。使用它使控件序列复制另一个序列,其默认值为排序的性质。

构造函数:

template<typename InIter>

map(InIter first, InIter last,

key_compare^ pred);

初始化该序列 [first,与排序的谓词 pred的last)的控件,序列。使用它使控件序列复制另一个序列,与指定的排序的性质。

构造函数:

map(System::Collections::Generic::IEnumerable<Key>^ right);

初始化具有默认的排序谓词的枚举数指定的顺序的控件序列, right。使用它使控件序列枚举数描述的副本另一个序列,具有默认排序的谓词的。

构造函数:

map(System::Collections::Generic::IEnumerable<Key>^ right,

key_compare^ pred);

初始化具有排序的谓词的 pred枚举数指定的顺序的控件序列, right。使用它使控件序列枚举数描述的副本另一个序列,具有指定的排序谓词的。

示例

// cliext_map_construct.cpp 
// compile with: /clr 
#include <cliext/map> 
 
typedef cliext::map<wchar_t, int> Mymap; 
int main() 
    { 
// construct an empty container 
    Mymap c1; 
    System::Console::WriteLine("size() = {0}", c1.size()); 
 
    c1.insert(Mymap::make_value(L'a', 1)); 
    c1.insert(Mymap::make_value(L'b', 2)); 
    c1.insert(Mymap::make_value(L'c', 3)); 
    for each (Mymap::value_type elem in c1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct with an ordering rule 
    Mymap c2 = cliext::greater_equal<wchar_t>(); 
    System::Console::WriteLine("size() = {0}", c2.size()); 
 
    c2.insert(c1.begin(), c1.end()); 
    for each (Mymap::value_type elem in c2) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct with an iterator range 
    Mymap c3(c1.begin(), c1.end()); 
    for each (Mymap::value_type elem in c3) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct with an iterator range and an ordering rule 
    Mymap c4(c1.begin(), c1.end(), 
        cliext::greater_equal<wchar_t>()); 
    for each (Mymap::value_type elem in c4) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct with an enumeration 
    Mymap c5(   // NOTE: cast is not needed 
        (System::Collections::Generic::IEnumerable< 
            Mymap::value_type>^)%c3); 
    for each (Mymap::value_type elem in c5) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct with an enumeration and an ordering rule 
    Mymap c6(   // NOTE: cast is not needed 
        (System::Collections::Generic::IEnumerable< 
            Mymap::value_type>^)%c3, 
                cliext::greater_equal<wchar_t>()); 
    for each (Mymap::value_type elem in c6) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct by copying another container 
    Mymap c7(c4); 
    for each (Mymap::value_type elem in c7) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct by copying a container handle 
    Mymap c8(%c3); 
    for each (Mymap::value_type elem in c8) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
  

要求

标题: <cliext/映射>

命名空间: cliext

请参见

参考

map (STL/CLR)

map::generic_container (STL/CLR)

map::operator= (STL/CLR)