Dela via


hash_multimap::hash_multimap (STL/CLR)

Constructs a container object.

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

Parameters

  • first
    Beginning of range to insert.

  • hashfn
    Hash function for mapping keys to buckets.

  • last
    End of range to insert.

  • pred
    Ordering predicate for the controlled sequence.

  • right
    Object or range to insert.

Remarks

The constructor:

hash_multimap();

initializes the controlled sequence with no elements, with the default ordering predicate key_compare(), and with the default hash function. You use it to specify an empty initial controlled sequence, with the default ordering predicate and hash function.

The constructor:

explicit hash_multimap(key_compare^ pred);

initializes the controlled sequence with no elements, with the ordering predicate pred, and with the default hash function. You use it to specify an empty initial controlled sequence, with the specified ordering predicate and the default hash function.

The constructor:

hash_multimap(key_compare^ pred, hasher^ hashfn);

initializes the controlled sequence with no elements, with the ordering predicate pred, and with the hash function hashfn. You use it to specify an empty initial controlled sequence, with the specified ordering predicate and hash function.

The constructor:

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

initializes the controlled sequence with the sequence [right.hash_multimap::begin (STL/CLR)(), right.hash_multimap::end (STL/CLR)()), with the default ordering predicate, and with the default hash function. You use it to specify an initial controlled sequence that is a copy of the sequence controlled by the hash_multimap object right, with the default ordering predicate and hash function.

The constructor:

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

initializes the controlled sequence with the sequence [right->hash_multimap::begin (STL/CLR)(), right->hash_multimap::end (STL/CLR)()), with the default ordering predicate, and with the default hash function. You use it to specify an initial controlled sequence that is a copy of the sequence controlled by the hash_multimap object right, with the default ordering predicate and hash function.

The constructor:

template<typename InIter>

hash_multimap(InIter first, InIter last);

initializes the controlled sequence with the sequence [first, last), with the default ordering predicate, and with the default hash function. You use it to make the controlled sequence a copy of another sequence, with the default ordering predicate and hash function.

The constructor:

template<typename InIter>

hash_multimap(InIter first, InIter last,

key_compare^ pred);

initializes the controlled sequence with the sequence [first, last), with the ordering predicate pred, and with the default hash function. You use it to make the controlled sequence a copy of another sequence, with the specified ordering predicate and the default hash function.

The constructor:

template<typename InIter>

hash_multimap(InIter first, InIter last,

key_compare^ pred, hasher^ hashfn);

initializes the controlled sequence with the sequence [first, last), with the ordering predicate pred, and with the hash function hashfn. You use it to make the controlled sequence a copy of another sequence, with the specified ordering predicate and hash function.

The constructor:

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

initializes the controlled sequence with the sequence designated by the enumerator right, with the default ordering predicate, and with the default hash function. You use it to make the controlled sequence a copy of another sequence described by an enumerator, with the default ordering predicate and hash function.

The constructor:

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

key_compare^ pred);

initializes the controlled sequence with the sequence designated by the enumerator right, with the ordering predicate pred, and with the default hash function. You use it to make the controlled sequence a copy of another sequence described by an enumerator, with the specified ordering predicate and default hash function.

The constructor:

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

key_compare^ pred, hasher^ hashfn);

initializes the controlled sequence with the sequence designated by the enumerator right, with the ordering predicate pred, and with the hash function hashfn. You use it to make the controlled sequence a copy of another sequence described by an enumerator, with the specified ordering predicate and hash function.

Example

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

 [a 1] [b 2] [c 3]
 [a 1] [b 2] [c 3]
 [c 3] [b 2] [a 1]

 [a 1] [b 2] [c 3]
 [a 1] [b 2] [c 3]
 [c 3] [b 2] [a 1]

 [a 1] [b 2] [c 3]
 [a 1] [b 2] [c 3]

Requirements

Header: <cliext/hash_map>

Namespace: cliext

See Also

Reference

hash_multimap (STL/CLR)

hash_multimap::generic_container (STL/CLR)

hash_multimap::operator= (STL/CLR)