hash_map::hash_map (STL/CLR)

建構容器物件。

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

參數

  • 第一個
    若要插入範圍的開頭。

  • hashfn
    雜湊雜湊桶的對應機碼的函的式。

  • last
    若要插入範圍的結尾。

  • pred
    排序受控制序列的述詞。

  • right
    物件,則要插入的範圍。

備註

建構函式:

hash_map();

以預設順序的述詞初始化任何項目時,受控制的序列key_compare(),並使用預設雜湊函式。您可以用它來指定空的初始受控制的序列,以預設順序的述詞與雜湊函式。

建構函式:

explicit hash_map(key_compare^ pred);

初始化任何項目時,排序的述詞與受控制的序列pred,並使用預設雜湊函式。您可以用它來指定空的初始受控制的序列,以指定順序的述詞和預設雜湊函式。

建構函式:

hash_map(key_compare^ pred, hasher^ hashfn);

初始化任何項目時,排序的述詞與受控制的序列pred,和雜湊函數與hashfn。您可以用它來指定空的初始受控制的序列,以指定順序的述詞和雜湊函數。

建構函式:

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

初始化受控制序列的序列[right.hash_map::begin (STL/CLR)(), right.hash_map::end (STL/CLR)())、 以預設順序的述詞,以及預設雜湊函式。您會用它來指定初始的受控制的序列是一份由 hash_map 物件來控制序列的right,預設排序述詞及雜湊函式。

建構函式:

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

初始化受控制序列的序列[right->hash_map::begin (STL/CLR)(), right->hash_map::end (STL/CLR)())、 以預設順序的述詞,以及預設雜湊函式。您會用它來指定初始的受控制的序列是一份由 hash_map 物件來控制序列的right,預設排序述詞及雜湊函式。

建構函式:

template<typename InIter>

hash_map(InIter first, InIter last);

初始化受控制序列的序列[first, last)、 以預設順序的述詞,以及預設雜湊函式。您可以使用它來變更受控制的序列的設定,另一個的順序,一份以預設順序的述詞與雜湊函式。

建構函式:

template<typename InIter>

hash_map(InIter first, InIter last,

key_compare^ pred);

初始化受控制序列的序列[first, last),排序的述詞與pred,並使用預設雜湊函式。您可以用它來建立受控制的序列的另一個序列,以指定順序的述詞和預設雜湊函式的複本。

建構函式:

template<typename InIter>

hash_map(InIter first, InIter last,

key_compare^ pred, hasher^ hashfn);

初始化受控制序列的序列[first, last),排序的述詞與pred,和雜湊函數與hashfn。您可以用它來建立受控制的序列的另一個序列,以指定順序的述詞和雜湊函數的複本。

建構函式:

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

初始化受控制的序列的列舉值所指定的順序與right、 以預設順序的述詞,以及預設雜湊函式。您可以用它來製作一份由列舉值,描述以預設順序的述詞與雜湊函式的另一個序列的受控制的序列。

建構函式:

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

key_compare^ pred);

初始化受控制的序列的列舉值所指定的順序與right,排序的述詞與pred,並使用預設雜湊函式。您可以用它來建立受控制的序列的列舉值,以指定順序的述詞和預設雜湊函數所描述的另一個序列的複本。

建構函式:

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

key_compare^ pred, hasher^ hashfn);

初始化受控制的序列的列舉值所指定的順序與right,排序的述詞與pred,和雜湊函數與hashfn。您可以用它來建立受控制的序列的列舉值,以指定順序的述詞和雜湊函數所描述的另一個序列的複本。

範例

// cliext_hash_map_construct.cpp 
// compile with: /clr 
#include <cliext/hash_map> 
 
int myfun(wchar_t key) 
    { // hash a key 
    return (key ^ 0xdeadbeef); 
    } 
 
typedef cliext::hash_map<wchar_t, int> Myhash_map; 
int main() 
    { 
// construct an empty container 
    Myhash_map c1; 
    System::Console::WriteLine("size() = {0}", c1.size()); 
 
    c1.insert(Myhash_map::make_value(L'a', 1)); 
    c1.insert(Myhash_map::make_value(L'b', 2)); 
    c1.insert(Myhash_map::make_value(L'c', 3)); 
    for each (Myhash_map::value_type elem in c1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct with an ordering rule 
    Myhash_map c2 = cliext::greater_equal<wchar_t>(); 
    System::Console::WriteLine("size() = {0}", c2.size()); 
 
    c2.insert(c1.begin(), c1.end()); 
    for each (Myhash_map::value_type elem in c2) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct with an ordering rule and hash function 
    Myhash_map c2h(cliext::greater_equal<wchar_t>(), 
        gcnew Myhash_map::hasher(&myfun)); 
    System::Console::WriteLine("size() = {0}", c2h.size()); 
 
    c2h.insert(c1.begin(), c1.end()); 
    for each (Myhash_map::value_type elem in c2h) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
    System::Console::WriteLine(); 
 
// construct with an iterator range 
    Myhash_map c3(c1.begin(), c1.end()); 
    for each (Myhash_map::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 
    Myhash_map c4(c1.begin(), c1.end(), 
        cliext::greater_equal<wchar_t>()); 
    for each (Myhash_map::value_type elem in c4) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct with an iterator range and an ordering rule and hash function 
    Myhash_map c4h(c1.begin(), c1.end(), 
        cliext::greater_equal<wchar_t>(), 
        gcnew Myhash_map::hasher(&myfun)); 
    for each (Myhash_map::value_type elem in c4h) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
    System::Console::WriteLine(); 
 
// construct with an enumeration 
    Myhash_map c5(   // NOTE: cast is not needed 
        (System::Collections::Generic::IEnumerable< 
            Myhash_map::value_type>^)%c3); 
    for each (Myhash_map::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 
    Myhash_map c6(   // NOTE: cast is not needed 
        (System::Collections::Generic::IEnumerable< 
            Myhash_map::value_type>^)%c3, 
                cliext::greater_equal<wchar_t>()); 
    for each (Myhash_map::value_type elem in c6) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct with an enumeration and an ordering rule and hash function 
    Myhash_map c6h(   // NOTE: cast is not needed 
        (System::Collections::Generic::IEnumerable< 
            Myhash_map::value_type>^)%c3, 
                cliext::greater_equal<wchar_t>(), 
                gcnew Myhash_map::hasher(&myfun)); 
    for each (Myhash_map::value_type elem in c6h) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
    System::Console::WriteLine(); 
 
// construct by copying another container 
    Myhash_map c7(c4); 
    for each (Myhash_map::value_type elem in c7) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
// construct by copying a container handle 
    Myhash_map c8(%c3); 
    for each (Myhash_map::value_type elem in c8) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
  

需求

標頭: < cliext/hash_map >

Namespace: cliext

請參閱

參考

hash_map (STL/CLR)

hash_map::generic_container (STL/CLR)

hash_map::operator= (STL/CLR)