hash_multimap (STL/CLR)hash_multimap (STL/CLR)

此模板类描述了一个对象,该对象控制具有双向访问权限的不同长度的元素序列。The template class describes an object that controls a varying-length sequence of elements that has bidirectional access. 使用容器可以将 hash_multimap 一系列元素作为哈希表管理,每个表项存储一个双向链接的节点列表,每个节点存储一个元素。You use the container hash_multimap to manage a sequence of elements as a hash table, each table entry storing a bidirectional linked list of nodes, and each node storing one element. 元素包含一个键,用于对序列进行排序,并包含一个映射值,此值将随之进行。An element consists of a key, for ordering the sequence, and a mapped value, which goes along for the ride.

在下面的说明中,与 GValue 相同:In the description below, GValue is the same as:

Microsoft::VisualC::StlClr::GenericPair<GKey, GMapped>

其中:where:

GKeyKey 相同,除非后者为 ref 类型,在这种情况下,它是 Key^GKey is the same as Key unless the latter is a ref type, in which case it is Key^

GMapped映射 相同,除非后者为 ref 类型,在这种情况下,它是 Mapped^GMapped is the same as Mapped unless the latter is a ref type, in which case it is Mapped^

语法Syntax

template<typename Key,
    typename Mapped>
    ref class hash_multimap
        :   public
        System::ICloneable,
        System::Collections::IEnumerable,
        System::Collections::ICollection,
        System::Collections::Generic::IEnumerable<GValue>,
        System::Collections::Generic::ICollection<GValue>,
        System::Collections::Generic::IList<GValue>,
        Microsoft::VisualC::StlClr::IHash<Gkey, GValue>
    { ..... };

parametersParameters

Key
受控序列中元素的键组件的类型。The type of the key component of an element in the controlled sequence.

Mapped
受控序列中元素的附加组件的类型。The type of the additional component of an element in the controlled sequence.

要求Requirements

标头:<cliext/hash_map>Header: <cliext/hash_map>

命名空间: cliextNamespace: cliext

声明Declarations

类型定义Type Definition 说明Description
hash_multimap::const_iterator (STL/CLR)hash_multimap::const_iterator (STL/CLR) 受控序列的常量迭代器的类型。The type of a constant iterator for the controlled sequence.
hash_multimap::const_reference (STL/CLR)hash_multimap::const_reference (STL/CLR) 元素的常量引用的类型。The type of a constant reference to an element.
hash_multimap::const_reverse_iterator (STL/CLR)hash_multimap::const_reverse_iterator (STL/CLR) 受控序列的常量反向迭代器的类型。The type of a constant reverse iterator for the controlled sequence.
hash_multimap::difference_type (STL/CLR)hash_multimap::difference_type (STL/CLR) 在两个元素之间可能有符号) 距离的 (的类型。The type of a (possibly signed) distance between two elements.
hash_multimap::generic_container (STL/CLR)hash_multimap::generic_container (STL/CLR) 容器的泛型接口的类型。The type of the generic interface for the container.
hash_multimap::generic_iterator (STL/CLR)hash_multimap::generic_iterator (STL/CLR) 容器的泛型接口的迭代器的类型。The type of an iterator for the generic interface for the container.
hash_multimap::generic_reverse_iterator (STL/CLR)hash_multimap::generic_reverse_iterator (STL/CLR) 容器的泛型接口的反向迭代器的类型。The type of a reverse iterator for the generic interface for the container.
hash_multimap::generic_value (STL/CLR)hash_multimap::generic_value (STL/CLR) 容器的泛型接口的元素类型。The type of an element for the generic interface for the container.
hash_multimap::hasher (STL/CLR)hash_multimap::hasher (STL/CLR) 键的哈希委托。The hashing delegate for a key.
hash_multimap::iterator (STL/CLR)hash_multimap::iterator (STL/CLR) 受控序列的迭代器的类型。The type of an iterator for the controlled sequence.
hash_multimap::key_compare (STL/CLR)hash_multimap::key_compare (STL/CLR) 两个键的排序委托。The ordering delegate for two keys.
hash_multimap::key_type (STL/CLR)hash_multimap::key_type (STL/CLR) 排序键的类型。The type of an ordering key.
hash_multimap::mapped_type (STL/CLR)hash_multimap::mapped_type (STL/CLR) 与每个键关联的映射值的类型。The type of the mapped value associated with each key.
hash_multimap::reference (STL/CLR)hash_multimap::reference (STL/CLR) 元素的引用的类型。The type of a reference to an element.
hash_multimap::reverse_iterator (STL/CLR)hash_multimap::reverse_iterator (STL/CLR) 受控序列的反向迭代器的类型。The type of a reverse iterator for the controlled sequence.
hash_multimap::size_type (STL/CLR)hash_multimap::size_type (STL/CLR) 两个元素之间 (非负) 距离的类型。The type of a (non-negative) distance between two elements.
hash_multimap::value_compare (STL/CLR)hash_multimap::value_compare (STL/CLR) 两个元素值的排序委托。The ordering delegate for two element values.
hash_multimap::value_type (STL/CLR)hash_multimap::value_type (STL/CLR) 元素的类型。The type of an element.
成员函数Member Function 描述Description
hash_multimap::begin (STL/CLR)hash_multimap::begin (STL/CLR) 指定受控序列的开头。Designates the beginning of the controlled sequence.
hash_multimap::bucket_count (STL/CLR)hash_multimap::bucket_count (STL/CLR) 计算 bucket 的数目。Counts the number of buckets.
hash_multimap::clear (STL/CLR)hash_multimap::clear (STL/CLR) 删除所有元素。Removes all elements.
hash_multimap::count (STL/CLR)hash_multimap::count (STL/CLR) 对与指定的键匹配的元素进行计数。Counts elements matching a specified key.
hash_multimap::empty (STL/CLR)hash_multimap::empty (STL/CLR) 测试元素是否存在。Tests whether no elements are present.
hash_multimap::end (STL/CLR)hash_multimap::end (STL/CLR) 指定受控序列的末尾。Designates the end of the controlled sequence.
hash_multimap::equal_range (STL/CLR)hash_multimap::equal_range (STL/CLR) 查找与指定键匹配的范围。Finds range that matches a specified key.
hash_multimap::erase (STL/CLR)hash_multimap::erase (STL/CLR) 移除指定位置处的元素。Removes elements at specified positions.
hash_multimap::find (STL/CLR)hash_multimap::find (STL/CLR) 查找与指定键匹配的元素。Finds an element that matches a specified key.
hash_multimap::hash_delegate (STL/CLR)hash_multimap::hash_delegate (STL/CLR) 复制密钥的哈希委托。Copies the hashing delegate for a key.
hash_multimap::hash_multimap (STL/CLR)hash_multimap::hash_multimap (STL/CLR) 构造容器对象。Constructs a container object.
hash_multimap::insert (STL/CLR)hash_multimap::insert (STL/CLR) 添加元素。Adds elements.
hash_multimap::key_comp (STL/CLR)hash_multimap::key_comp (STL/CLR) 复制两个键的排序委托。Copies the ordering delegate for two keys.
hash_multimap::load_factor (STL/CLR)hash_multimap::load_factor (STL/CLR) 对每个存储桶的平均元素数进行计数。Counts the average elements per bucket.
hash_multimap::lower_bound (STL/CLR)hash_multimap::lower_bound (STL/CLR) 查找与指定键匹配的范围的开头。Finds beginning of range that matches a specified key.
hash_multimap::make_value (STL/CLR)hash_multimap::make_value (STL/CLR) 构造一个值对象。Constructs a value object.
hash_multimap::max_load_factor (STL/CLR)hash_multimap::max_load_factor (STL/CLR) 获取或设置每个存储桶的最多元素数。Gets or sets the maximum elements per bucket.
hash_multimap::rbegin (STL/CLR)hash_multimap::rbegin (STL/CLR) 指定反向受控序列的开头。Designates the beginning of the reversed controlled sequence.
hash_multimap::rehash (STL/CLR)hash_multimap::rehash (STL/CLR) 重新生成哈希表。Rebuilds the hash table.
hash_multimap::rend (STL/CLR)hash_multimap::rend (STL/CLR) 指定反向受控序列的末尾。Designates the end of the reversed controlled sequence.
hash_multimap::size (STL/CLR)hash_multimap::size (STL/CLR) 对元素数进行计数。Counts the number of elements.
hash_multimap::swap (STL/CLR)hash_multimap::swap (STL/CLR) 交换两个容器的内容。Swaps the contents of two containers.
hash_multimap::to_array (STL/CLR)hash_multimap::to_array (STL/CLR) 将受控序列复制到新数组。Copies the controlled sequence to a new array.
hash_multimap::upper_bound (STL/CLR)hash_multimap::upper_bound (STL/CLR) 查找与指定键匹配的范围的末尾。Finds end of range that matches a specified key.
hash_multimap::value_comp (STL/CLR)hash_multimap::value_comp (STL/CLR) 复制两个元素值的排序委托。Copies the ordering delegate for two element values.
运算符Operator 描述Description
hash_multimap::operator= (STL/CLR)hash_multimap::operator= (STL/CLR) 替换受控序列。Replaces the controlled sequence.

界面Interfaces

接口Interface 描述Description
ICloneable 复制对象。Duplicate an object.
IEnumerable 通过元素进行排序。Sequence through elements.
ICollection 维护元素组。Maintain group of elements.
IEnumerable<T> 通过类型化元素进行排序。Sequence through typed elements.
ICollection<T> 维护类型化元素组。Maintain group of typed elements.
IHash<Key, Value>IHash<Key, Value> 维护泛型容器。Maintain generic container.

备注Remarks

对象为其控制的序列分配并释放存储,并将其控制为双向链接列表中的单个节点。The object allocates and frees storage for the sequence it controls as individual nodes in a bidirectional linked list. 为了加快访问速度,对象还会在哈希表) (的列表中保留一个长度可变的指针数组,从而有效地将整个列表作为子列表或存储桶序列进行管理。To speed access, the object also maintains a varying-length array of pointers into the list (the hash table), effectively managing the whole list as a sequence of sublists, or buckets. 它通过更改节点之间的链接,将元素插入到存储桶中,而不是将一个节点的内容复制到另一个节点。It inserts elements into a bucket that it keeps ordered by altering the links between nodes, never by copying the contents of one node to another. 这意味着,无需干扰剩余元素,即可随意插入和移除元素。That means you can insert and remove elements freely without disturbing remaining elements.

对象通过调用 hash_set:: key_compare 类型的存储委托对象对其控制的每个存储桶进行排序 (STL/CLR) The object orders each bucket it controls by calling a stored delegate object of type hash_set::key_compare (STL/CLR). 构造 hash_set 时,可以指定存储的委托对象;如果指定 "无委托对象",则默认值为 "比较" operator<=(key_type, key_type)You can specify the stored delegate object when you construct the hash_set; if you specify no delegate object, the default is the comparison operator<=(key_type, key_type).

可以通过调用成员函数hash_set:: key_comp (STL/CLR) 来访问存储的委托对象 ()You access the stored delegate object by calling the member function hash_set::key_comp (STL/CLR)(). 此类委托对象必须在类型 hash_set:: key_type (STL/CLR) 的键之间定义等效顺序。Such a delegate object must define equivalent ordering between keys of type hash_set::key_type (STL/CLR). 这意味着,对于任意两个密钥 XYThat means, for any two keys X and Y:

key_comp()(X, Y) 针对每个调用返回相同的布尔值结果。key_comp()(X, Y) returns the same Boolean result on every call.

如果 key_comp()(X, Y) && key_comp()(Y, X) 为 true,则 X Y 认为和具有等效的排序。If key_comp()(X, Y) && key_comp()(Y, X) is true, then X and Y are said to have equivalent ordering.

行为类似的任何排序规则 operator<=(key_type, key_type) operator>=(key_type, key_type)operator==(key_type, key_type) 定义 eqivalent 排序规则。Any ordering rule that behaves like operator<=(key_type, key_type), operator>=(key_type, key_type) or operator==(key_type, key_type) defines eqivalent ordering.

请注意,容器仅确保其键具有等效排序的元素 (以及与相同整数值) 的哈希值在存储桶中相邻。Note that the container ensures only that elements whose keys have equivalent ordering (and which hash to the same integer value) are adjacent within a bucket. 与模板类 hash_map (STL/CLR) 不同,模板类的对象 hash_multimap 不需要所有元素的键都是唯一的。Unlike template class hash_map (STL/CLR), an object of template class hash_multimap does not require that keys for all elements are unique. (两个或更多的密钥可以具有等效的排序。 ) (Two or more keys can have equivalent ordering.)

对象通过调用存储的委托对象类型 hash_set:: hasher (STL/CLR) 来确定哪个 bucket 应包含给定的排序关键字。The object determines which bucket should contain a given ordering key by calling a stored delegate object of type hash_set::hasher (STL/CLR). 可以通过调用成员函数 hash_set:: hash_delegate 来访问此存储对象, (STL/CLR) () 获取依赖于键值的整数值。You access this stored object by calling the member function hash_set::hash_delegate (STL/CLR)() to obtain an integer value that depends on the key value. 构造 hash_set 时,可以指定存储的委托对象;如果未指定任何委托对象,则默认为函数 System::Object::hash_value(key_type)You can specify the stored delegate object when you construct the hash_set; if you specify no delegate object, the default is the function System::Object::hash_value(key_type). 这意味着,对于任何密钥 XYThat means, for any keys X and Y:

hash_delegate()(X) 针对每个调用返回相同的整数结果。hash_delegate()(X) returns the same integer result on every call.

如果 XY 具有等效的排序,则 hash_delegate()(X) 应返回与相同的整数结果 hash_delegate()(Y)If X and Y have equivalent ordering, then hash_delegate()(X) should return the same integer result as hash_delegate()(Y).

每个元素都包含一个单独的键和一个映射值。Each element contains a separate key and a mapped value. 序列以允许查找、插入和移除任意元素的方式表示,这些操作与序列中的元素数量无关 (常量时间) -至少最适用于事例中的元素数量。The sequence is represented in a way that permits lookup, insertion, and removal of an arbitrary element with a number of operations that is independent of the number of elements in the sequence (constant time) -- at least in the best of cases. 此外,插入元素不会使迭代器失效,移除元素仅会使指向已移除元素的迭代器失效。Moreover, inserting an element invalidates no iterators, and removing an element invalidates only those iterators which point at the removed element.

但是,如果哈希值不是均匀分布的,则哈希表可能会退化。If hashed values are not uniformly distributed, however, a hash table can degenerate. 对于始终返回相同值的哈希函数,查找、插入和移除与序列中的元素数成正比, (线性时间) 。In the extreme -- for a hash function that always returns the same value -- lookup, insertion, and removal are proportional to the number of elements in the sequence (linear time). 容器可用于选择合理的哈希函数、平均存储桶大小和哈希表大小 (bucket) 的总数量,但你可以覆盖这些选项中的任何一个或全部。The container endeavors to choose a reasonable hash function, mean bucket size, and hash-table size (total number of buckets), but you can override any or all of these choices. 例如,函数 hash_set:: max_load_factor (stl/clr) ,hash_set :: rehash (stl/clr) See, for example, the functions hash_set::max_load_factor (STL/CLR) and hash_set::rehash (STL/CLR).

Hash_multimap 支持双向迭代器,这意味着,可以在给定指定了受控序列元素的迭代器的情况下单步执行相邻元素。A hash_multimap supports bidirectional iterators, which means you can step to adjacent elements given an iterator that designates an element in the controlled sequence. 特殊头节点对应于hash_multimap:: end (STL/CLR) 返回的迭代器 ()A special head node corresponds to the iterator returned by hash_multimap::end (STL/CLR)(). 可以递减此迭代器以到达受控序列中的最后一个元素(如果存在)。You can decrement this iterator to reach the last element in the controlled sequence, if present. 可以递增 hash_multimap 迭代器来访问头节点,然后将其与相等 end()You can increment a hash_multimap iterator to reach the head node, and it will then compare equal to end(). 但不能取消引用返回的迭代器 end()But you cannot dereference the iterator returned by end().

请注意,不能直接引用 hash_multimap 元素,因为它的数字位置需要随机访问迭代器。Note that you cannot refer to a hash_multimap element directly given its numerical position -- that requires a random-access iterator.

Hash_multimap 迭代器将句柄存储到其关联的 hash_multimap 节点,后者又将句柄存储到其关联的容器。A hash_multimap iterator stores a handle to its associated hash_multimap node, which in turn stores a handle to its associated container. 只能将迭代器与其关联的容器对象一起使用。You can use iterators only with their associated container objects. 只要 hash_multimap 迭代器的关联 hash_multimap 节点与某些 hash_multimap 相关联,就会保持有效。A hash_multimap iterator remains valid so long as its associated hash_multimap node is associated with some hash_multimap. 而且,有效的迭代器是 dereferencable 的,您可以使用它来访问或更改它指定的元素值,但前提是它不等于 end()Moreover, a valid iterator is dereferencable -- you can use it to access or alter the element value it designates -- so long as it is not equal to end().

清除或删除元素会调用析构函数以获取其存储的值。Erasing or removing an element calls the destructor for its stored value. 销毁容器将清除所有元素。Destroying the container erases all elements. 因此,其元素类型为 ref 类的容器可确保没有元素长于容器。Thus, a container whose element type is a ref class ensures that no elements outlive the container. 但请注意,句柄的容器 会销毁其元素。Note, however, that a container of handles does not destroy its elements.

成员Members

hash_multimap:: begin (STL/CLR) hash_multimap::begin (STL/CLR)

指定受控序列的开头。Designates the beginning of the controlled sequence.

语法Syntax

iterator begin();

备注Remarks

成员函数返回一个双向迭代器,该迭代器指定受控序列的第一个元素,或刚超出空序列的末尾。The member function returns a bidirectional iterator that designates the first element of the controlled sequence, or just beyond the end of an empty sequence. 用于获取一个迭代器,该迭代器指定受控序列的 current 开头,但如果受控序列的长度发生更改,则该迭代器的状态也会发生更改。You use it to obtain an iterator that designates the current beginning of the controlled sequence, but its status can change if the length of the controlled sequence changes.

示例Example

// cliext_hash_multimap_begin.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect first two items
    Myhash_multimap::iterator it = c1.begin();
    System::Console::WriteLine("*begin() = [{0} {1}]",
        it->first, it->second);
    ++it;
    System::Console::WriteLine("*++begin() = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*begin() = [a 1]
*++begin() = [b 2]

hash_multimap:: bucket_count (STL/CLR) hash_multimap::bucket_count (STL/CLR)

计算 bucket 的数目。Counts the number of buckets.

语法Syntax

int bucket_count();

备注Remarks

成员函数返回当前的存储桶数。The member functions returns the current number of buckets. 您可以使用它来确定哈希表的大小。You use it to determine the size of the hash table.

示例Example

// cliext_hash_multimap_bucket_count.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1 = gcnew Myhash_multimap;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect current parameters
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // change max_load_factor and redisplay
    c1.max_load_factor(0.25f);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // rehash and redisplay
    c1.rehash(100);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    return (0);
    }
[a 1] [b 2] [c 3]
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4

bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25

bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25

hash_multimap:: clear (STL/CLR) hash_multimap::clear (STL/CLR)

删除所有元素。Removes all elements.

语法Syntax

void clear();

备注Remarks

成员函数有效地调用hash_multimap:: erase (stl/clr) ( hash_multimap:: begin (stl/clr) hash_multimap (), :: end (stl/clr) ())The member function effectively calls hash_multimap::erase (STL/CLR)( hash_multimap::begin (STL/CLR)(), hash_multimap::end (STL/CLR)()). 用于确保受控序列为空。You use it to ensure that the controlled sequence is empty.

示例Example

// cliext_hash_multimap_clear.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // clear the container and reinspect
    c1.clear();
    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));

    // display contents " [a 1] [b 2]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());
    return (0);
    }
[a 1] [b 2] [c 3]
size() = 0
[a 1] [b 2]
size() = 0

hash_multimap:: const_iterator (STL/CLR) hash_multimap::const_iterator (STL/CLR)

受控序列的常量迭代器的类型。The type of a constant iterator for the controlled sequence.

语法Syntax

typedef T2 const_iterator;

备注Remarks

该类型描述 T2 可用作受控序列的常量双向迭代器的未指定类型的对象。The type describes an object of unspecified type T2 that can serve as a constant bidirectional iterator for the controlled sequence.

示例Example

// cliext_hash_multimap_const_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    Myhash_multimap::const_iterator cit = c1.begin();
    for (; cit != c1.end(); ++cit)
        System::Console::Write("[{0} {1}] ", cit->first, cit->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

hash_multimap:: const_reference (STL/CLR) hash_multimap::const_reference (STL/CLR)

元素的常量引用的类型。The type of a constant reference to an element.

语法Syntax

typedef value_type% const_reference;

备注Remarks

类型描述对元素的常量引用。The type describes a constant reference to an element.

示例Example

// cliext_hash_multimap_const_reference.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    Myhash_multimap::const_iterator cit = c1.begin();
    for (; cit != c1.end(); ++cit)
        {   // get a const reference to an element
        Myhash_multimap::const_reference cref = *cit;
        System::Console::Write("[{0} {1}] ", cref->first, cref->second);
        }
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

hash_multimap:: const_reverse_iterator (STL/CLR) hash_multimap::const_reverse_iterator (STL/CLR)

受控序列的常量反向迭代器的类型。The type of a constant reverse iterator for the controlled sequence..

语法Syntax

typedef T4 const_reverse_iterator;

备注Remarks

该类型描述 T4 可用作受控序列的常量反向迭代器的未指定类型的对象。The type describes an object of unspecified type T4 that can serve as a constant reverse iterator for the controlled sequence.

示例Example

// cliext_hash_multimap_const_reverse_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]" reversed
    Myhash_multimap::const_reverse_iterator crit = c1.rbegin();
    for (; crit != c1.rend(); ++crit)
        System::Console::Write("[{0} {1}] ", crit->first, crit->second);
    System::Console::WriteLine();
    return (0);
    }
[c 3] [b 2] [a 1]

hash_multimap:: count (STL/CLR) hash_multimap::count (STL/CLR)

查找与指定键匹配的元素数。Finds the number of elements matching a specified key.

语法Syntax

size_type count(key_type key);

parametersParameters

keykey
要搜索的键值。Key value to search for.

备注Remarks

该成员函数将返回受控序列中与 具有等效排序的元素的数目。The member function returns the number of elements in the controlled sequence that have equivalent ordering with key. 用于确定受控序列中当前与指定键匹配的元素数。You use it to determine the number of elements currently in the controlled sequence that match a specified key.

示例Example

// cliext_hash_multimap_count.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("count(L'A') = {0}", c1.count(L'A'));
    System::Console::WriteLine("count(L'b') = {0}", c1.count(L'b'));
    System::Console::WriteLine("count(L'C') = {0}", c1.count(L'C'));
    return (0);
    }
[a 1] [b 2] [c 3]
count(L'A') = 0
count(L'b') = 1
count(L'C') = 0

hash_multimap::d ifference_type (STL/CLR) hash_multimap::difference_type (STL/CLR)

两个元素间的带符号距离的类型。The types of a signed distance between two elements.

语法Syntax

typedef int difference_type;

备注Remarks

该类型描述了可能的负元素计数。The type describes a possibly negative element count.

示例Example

// cliext_hash_multimap_difference_type.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // compute positive difference
    Myhash_multimap::difference_type diff = 0;
    for (Myhash_multimap::iterator it = c1.begin(); it != c1.end(); ++it)
        ++diff;
    System::Console::WriteLine("end()-begin() = {0}", diff);

    // compute negative difference
    diff = 0;
    for (Myhash_multimap::iterator it = c1.end(); it != c1.begin(); --it)
        --diff;
    System::Console::WriteLine("begin()-end() = {0}", diff);
    return (0);
    }
[a 1] [b 2] [c 3]
end()-begin() = 3
begin()-end() = -3

hash_multimap:: empty (STL/CLR) hash_multimap::empty (STL/CLR)

测试元素是否存在。Tests whether no elements are present.

语法Syntax

bool empty();

备注Remarks

对于空受控序列,该成员函数返回 true。The member function returns true for an empty controlled sequence. 它等效于STL/CLR) hash_multimap:: size ( () == 0It is equivalent to hash_multimap::size (STL/CLR)() == 0. 用于测试 hash_multimap 是否为空。You use it to test whether the hash_multimap is empty.

示例Example

// cliext_hash_multimap_empty.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    System::Console::WriteLine("size() = {0}", c1.size());
    System::Console::WriteLine("empty() = {0}", c1.empty());

    // clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());
    System::Console::WriteLine("empty() = {0}", c1.empty());
    return (0);
    }
[a 1] [b 2] [c 3]
size() = 3
empty() = False
size() = 0
empty() = True

hash_multimap:: end (STL/CLR) hash_multimap::end (STL/CLR)

指定受控序列的末尾。Designates the end of the controlled sequence.

语法Syntax

iterator end();

备注Remarks

成员函数返回一个双向迭代器,它指向刚超出受控序列末尾的位置。The member function returns a bidirectional iterator that points just beyond the end of the controlled sequence. 用于获取一个迭代器,该迭代器指定受控序列的末尾;如果受控序列的长度发生更改,则其状态不会更改。You use it to obtain an iterator that designates the end of the controlled sequence; its status doesn not change if the length of the controlled sequence changes.

示例Example

// cliext_hash_multimap_end.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect last two items
    Myhash_multimap::iterator it = c1.end();
    --it;
    --it;
    System::Console::WriteLine("*-- --end() = [{0} {1}]",
        it->first, it->second);
    ++it;
    System::Console::WriteLine("*--end() = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*-- --end() = [b 2]
*--end() = [c 3]

hash_multimap:: equal_range (STL/CLR) hash_multimap::equal_range (STL/CLR)

查找与指定键匹配的范围。Finds range that matches a specified key.

语法Syntax

cliext::pair<iterator, iterator> equal_range(key_type key);

parametersParameters

keykey
要搜索的键值。Key value to search for.

备注Remarks

此成员函数返回一对迭代器 cliext::pair<iterator, iterator>( hash_multimap:: lower_bound (stl/clr) (key), hash_multimap:: upper_bound (STL/clr) (key))The member function returns a pair of iterators cliext::pair<iterator, iterator>( hash_multimap::lower_bound (STL/CLR)(key), hash_multimap::upper_bound (STL/CLR)(key)). 用于确定受控序列中当前与指定键匹配的元素范围。You use it to determine the range of elements currently in the controlled sequence that match a specified key.

示例Example

// cliext_hash_multimap_equal_range.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
typedef Myhash_multimap::pair_iter_iter Pairii;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // display results of failed search
    Pairii pair1 = c1.equal_range(L'x');
    System::Console::WriteLine("equal_range(L'x') empty = {0}",
        pair1.first == pair1.second);

    // display results of successful search
    pair1 = c1.equal_range(L'b');
    for (; pair1.first != pair1.second; ++pair1.first)
        System::Console::Write("[{0} {1}] ",
            pair1.first->first, pair1.first->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
equal_range(L'x') empty = True
[b 2]

hash_multimap:: erase (STL/CLR) hash_multimap::erase (STL/CLR)

移除指定位置处的元素。Removes elements at specified positions.

语法Syntax

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

parametersParameters

firstfirst
要清除的范围的开头。Beginning of range to erase.

keykey
要清除的键值。Key value to erase.

lastlast
要清除的范围的结束。End of range to erase.

wherewhere
要清除的元素。Element to erase.

备注Remarks

第一个成员函数删除由 where 指向的受控序列的元素,并返回一个迭代器,该迭代器指定在删除的元素之外保留的第一个元素; 如果此类元素不存在,则为 hash_multimap:) (()The first member function removes the element of the controlled sequence pointed to by where, and returns an iterator that designates the first element remaining beyond the element removed, or hash_multimap::end (STL/CLR)() if no such element exists. 使用它可以删除单个元素。You use it to remove a single element.

第二个成员函数删除范围 [,) 中的受控序列的元素, first last 并返回一个迭代器,该迭代器指定删除的任何元素之外保留的第一个元素; end() 如果此类元素不存在,则为。The second member function removes the elements of the controlled sequence in the range [first, last), and returns an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.. 使用它可以删除零个或多个连续元素。You use it to remove zero or more contiguous elements.

第三个成员函数删除受控序列中其键与 具有等效顺序的任何元素,并返回所移除的元素数的计数。The third member function removes any element of the controlled sequence whose key has equivalent ordering to key, and returns a count of the number of elements removed. 使用它可删除与指定键匹配的所有元素并对其进行计数。You use it to remove and count all elements that match a specified key.

每个元素擦除与受控序列中的元素数的对数成正比。Each element erasure takes time proportional to the logarithm of the number of elements in the controlled sequence.

示例Example

// cliext_hash_multimap_erase.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    cliext::hash_multimap<wchar_t, int> c1;
    c1.insert(cliext::hash_multimap<wchar_t, int>::make_value(L'a', 1));
    c1.insert(cliext::hash_multimap<wchar_t, int>::make_value(L'b', 2));
    c1.insert(cliext::hash_multimap<wchar_t, int>::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (cliext::hash_multimap<wchar_t, int>::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // erase an element and reinspect
    cliext::hash_multimap<wchar_t, int>::iterator it =
        c1.erase(c1.begin());
    System::Console::WriteLine("erase(begin()) = [{0} {1}]",
        it->first, it->second);

    // add elements and display " b c d e"
    c1.insert(cliext::hash_multimap<wchar_t, int>::make_value(L'd', 4));
    c1.insert(cliext::hash_multimap<wchar_t, int>::make_value(L'e', 5));
    for each (cliext::hash_multimap<wchar_t, int>::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // erase all but end
    it = c1.end();
    it = c1.erase(c1.begin(), --it);
    System::Console::WriteLine("erase(begin(), end()-1) = [{0} {1}]",
        it->first, it->second);
    System::Console::WriteLine("size() = {0}", c1.size());

    // erase end
    System::Console::WriteLine("erase(L'x') = {0}", c1.erase(L'x'));
    System::Console::WriteLine("erase(L'e') = {0}", c1.erase(L'e'));
    return (0);
    }
[a 1] [b 2] [c 3]
erase(begin()) = [b 2]
[b 2] [c 3] [d 4] [e 5]
erase(begin(), end()-1) = [e 5]
size() = 1
erase(L'x') = 0
erase(L'e') = 1

hash_multimap:: find (STL/CLR) hash_multimap::find (STL/CLR)

查找与指定键匹配的元素。Finds an element that matches a specified key.

语法Syntax

iterator find(key_type key);

parametersParameters

keykey
要搜索的键值。Key value to search for.

备注Remarks

如果受控序列中的至少一个元素具有与 等效的排序,则成员函数将返回一个指定这些元素之一的迭代器;否则,它将返回 hash_multimap:: end (STL/CLR) ()If at least one element in the controlled sequence has equivalent ordering with key, the member function returns an iterator designating one of those elements; otherwise it returns hash_multimap::end (STL/CLR)(). 用于查找当前位于受控序列中的元素,该元素与指定的键匹配。You use it to locate an element currently in the controlled sequence that matches a specified key.

示例Example

// cliext_hash_multimap_find.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("find {0} = {1}",
        L'A', c1.find(L'A') != c1.end());

    Myhash_multimap::iterator it = c1.find(L'b');
    System::Console::WriteLine("find {0} = [{1} {2}]",
        L'b', it->first, it->second);

    System::Console::WriteLine("find {0} = {1}",
        L'C', c1.find(L'C') != c1.end());
    return (0);
    }
[a 1] [b 2] [c 3]
find A = False
find b = [b 2]
find C = False

hash_multimap:: generic_container (STL/CLR) hash_multimap::generic_container (STL/CLR)

容器的泛型接口的类型。The type of the generic interface for the container.

语法Syntax

typedef Microsoft::VisualC::StlClr::
    IHash<GKey, GValue>
    generic_container;

备注Remarks

类型描述此模板容器类的泛型接口。The type describes the generic interface for this template container class.

示例Example

// cliext_hash_multimap_generic_container.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Myhash_multimap::generic_container^ gc1 = %c1;
    for each (Myhash_multimap::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // modify generic and display original
    gc1->insert(Myhash_multimap::make_value(L'd', 4));
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // modify original and display generic
    c1.insert(Myhash_multimap::make_value(L'e', 5));
    for each (Myhash_multimap::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3] [d 4]
[a 1] [b 2] [c 3] [d 4] [e 5]

hash_multimap:: generic_iterator (STL/CLR) hash_multimap::generic_iterator (STL/CLR)

与容器的泛型接口一起使用的迭代器的类型。The type of an iterator for use with the generic interface for the container.

语法Syntax

typedef Microsoft::VisualC::StlClr::Generic::
    ContainerBidirectionalIterator<generic_value>
    generic_iterator;

备注Remarks

该类型描述了可与此模板容器类的泛型接口一起使用的泛型迭代器。The type describes a generic iterator that can be used with the generic interface for this template container class.

示例Example

// cliext_hash_multimap_generic_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Myhash_multimap::generic_container^ gc1 = %c1;
    for each (Myhash_multimap::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // get an element and display it
    Myhash_multimap::generic_iterator gcit = gc1->begin();
    Myhash_multimap::generic_value gcval = *gcit;
    System::Console::Write("[{0} {1}] ", gcval->first, gcval->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[a 1]

hash_multimap:: generic_reverse_iterator (STL/CLR) hash_multimap::generic_reverse_iterator (STL/CLR)

用于容器的泛型接口的反向迭代器的类型。The type of a reverse iterator for use with the generic interface for the container.

语法Syntax

typedef Microsoft::VisualC::StlClr::Generic::
    ReverseRandomAccessIterator<generic_value>
    generic_reverse_iterator;

备注Remarks

该类型描述了可与此模板容器类的泛型接口一起使用的一般反向迭代器。The type describes a generic reverse iterator that can be used with the generic interface for this template container class.

示例Example

// cliext_hash_multimap_generic_reverse_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Myhash_multimap::generic_container^ gc1 = %c1;
    for each (Myhash_multimap::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // get an element and display it
    Myhash_multimap::generic_reverse_iterator gcit = gc1->rbegin();
    Myhash_multimap::generic_value gcval = *gcit;
    System::Console::WriteLine("[{0} {1}] ", gcval->first, gcval->second);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[c 3]

hash_multimap:: generic_value (STL/CLR) hash_multimap::generic_value (STL/CLR)

用于容器的泛型接口的元素类型。The type of an element for use with the generic interface for the container.

语法Syntax

typedef GValue generic_value;

备注Remarks

类型描述了一个类型为的对象 GValue ,该对象描述用于此模板容器类的泛型接口的存储元素值。The type describes an object of type GValue that describes the stored element value for use with the generic interface for this template container class.

示例Example

// cliext_hash_multimap_generic_value.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Myhash_multimap::generic_container^ gc1 = %c1;
    for each (Myhash_multimap::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // get an element and display it
    Myhash_multimap::generic_iterator gcit = gc1->begin();
    Myhash_multimap::generic_value gcval = *gcit;
    System::Console::WriteLine("[{0} {1}] ", gcval->first, gcval->second);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[a 1]

hash_multimap:: hash_delegate (STL/CLR) hash_multimap::hash_delegate (STL/CLR)

查找与指定键匹配的元素。Finds an element that matches a specified key.

语法Syntax

hasher^ hash_delegate();

备注Remarks

该成员函数将返回用于将键值转换为整数的委托。The member function returns the delegate used to convert a key value to an integer. 用于对密钥进行哈希处理。You use it to hash a key.

示例Example

// cliext_hash_multimap_hash_delegate.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    Myhash_multimap::hasher^ myhash = c1.hash_delegate();

    System::Console::WriteLine("hash(L'a') = {0}", myhash(L'a'));
    System::Console::WriteLine("hash(L'b') = {0}", myhash(L'b'));
    return (0);
    }
hash(L'a') = 1616896120
hash(L'b') = 570892832

hash_multimap:: hash_multimap (STL/CLR) hash_multimap::hash_multimap (STL/CLR)

构造容器对象。Constructs a container object.

语法Syntax

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);

parametersParameters

firstfirst
要插入的范围的开头。Beginning of range to insert.

hashfnhashfn
用于将密钥映射到存储桶的哈希函数。Hash function for mapping keys to buckets.

lastlast
要插入的范围的末尾。End of range to insert.

predpred
受控序列的排序谓词。Ordering predicate for the controlled sequence.

然后right
要插入的对象或范围。Object or range to insert.

备注Remarks

构造函数:The constructor:

hash_multimap();

用默认的排序谓词 key_compare() 和默认哈希函数初始化受控序列,其中不包含任何元素。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);

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);

pred 和哈希函数 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);

用序列 [ right.begin()right.end()) 和默认的哈希函数初始化受控序列。initializes the controlled sequence with the sequence [right.begin(), right.end()), with the default ordering predicate, and with the default hash function. 用于指定初始受控序列,该序列是由 hash_multimap 对象 权限 控制的序列的副本,具有默认的排序谓词和哈希函数。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);

用序列 [ right->begin()right->end()) 和默认的哈希函数初始化受控序列。initializes the controlled sequence with the sequence [right->begin(), right->end()), with the default ordering predicate, and with the default hash function. 用于指定初始受控序列,该序列是由 hash_multimap 对象 权限 控制的序列的副本,具有默认的排序谓词和哈希函数。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);

用序列 [ firstlast) 和默认的哈希函数初始化受控序列。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);

first last) 序列谓词 " 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);

用序列谓词 [,) 初始化受控序列, first last 并将排序谓词 pred 和哈希函数 hashfninitializes 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);

使用由枚举器 右端 指定的序列、排序谓词 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);

使用由枚举器 右端 指定的序列、排序谓词 pred 和哈希函数 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]

hash_multimap:: hasher (STL/CLR) hash_multimap::hasher (STL/CLR)

键的哈希委托。The hashing delegate for a key.

语法Syntax

Microsoft::VisualC::StlClr::UnaryDelegate<GKey, int>
    hasher;

备注Remarks

该类型描述了将键值转换为整数的委托。The type describes a delegate that converts a key value to an integer.

示例Example

// cliext_hash_multimap_hasher.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    Myhash_multimap::hasher^ myhash = c1.hash_delegate();

    System::Console::WriteLine("hash(L'a') = {0}", myhash(L'a'));
    System::Console::WriteLine("hash(L'b') = {0}", myhash(L'b'));
    return (0);
    }
hash(L'a') = 1616896120
hash(L'b') = 570892832

hash_multimap:: insert (STL/CLR) hash_multimap::insert (STL/CLR)

添加元素。Adds elements.

语法Syntax

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);

parametersParameters

firstfirst
要插入的范围的开头。Beginning of range to insert.

lastlast
要插入的范围的末尾。End of range to insert.

然后right
要插入的枚举。Enumeration to insert.

初始值val
要插入的项值。Key value to insert.

wherewhere
容器中要插入的位置 (提示仅) 。Where in container to insert (hint only).

备注Remarks

每个成员函数都插入由剩余操作数指定的序列。Each of the member functions inserts a sequence specified by the remaining operands.

第一个成员函数插入一个具有值 val 的元素,并返回指定新插入的元素的迭代器。The first member function inserts an element with value val, and returns an iterator that designates the newly inserted element. 用于插入单个元素。You use it to insert a single element.

第二个成员函数插入具有值 val 的元素,使用 where 作为提示 (提高性能) ,并返回指定新插入的元素的迭代器。The second member function inserts an element with value val, using where as a hint (to improve performance), and returns an iterator that designates the newly inserted element. 使用它可以插入一个元素,该元素可能与你知道的元素相邻。You use it to insert a single element which might be adjacent to an element you know.

第三个成员函数插入序列 [ firstlast) 。The third member function inserts the sequence [first, last). 用于插入从另一个序列复制的零个或多个元素。You use it to insert zero or more elements copied from another sequence.

第四个成员函数插入由 权限 指定的序列。The fourth member function inserts the sequence designated by the right. 使用它可以插入枚举器描述的序列。You use it to insert a sequence described by an enumerator.

每个元素插入时间与受控序列中的元素数的对数成正比。Each element insertion takes time proportional to the logarithm of the number of elements in the controlled sequence. 但是,如果指定一个在插入点附近指定元素的提示,则可能会在分期常量时间内进行插入。Insertion can occur in amortized constant time, however, given a hint that designates an element adjacent to the insertion point.

示例Example

// cliext_hash_multimap_insert.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert a single value, unique and duplicate
    Myhash_multimap::iterator it =
        c1.insert(Myhash_multimap::make_value(L'x', 24));
    System::Console::WriteLine("insert([L'x' 24]) = [{0} {1}]",
        it->first, it->second);

    it = c1.insert(Myhash_multimap::make_value(L'b', 2));
    System::Console::WriteLine("insert([L'b' 2]) = [{0} {1}]",
        it->first, it->second);

    for each (Myhash_multimap::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(), Myhash_multimap::make_value(L'y', 25));
    System::Console::WriteLine("insert(begin(), [L'y' 25]) = [{0} {1}]",
        it->first, it->second);
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert an iterator range
    Myhash_multimap c2;
    it = c1.end();
    c2.insert(c1.begin(), --it);
    for each (Myhash_multimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert an enumeration
    Myhash_multimap c3;
    c3.insert(   // NOTE: cast is not needed
        (System::Collections::Generic::
            IEnumerable<Myhash_multimap::value_type>^)%c1);
    for each (Myhash_multimap::value_type elem in c3)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
insert([L'x' 24]) = [x 24]
insert([L'b' 2]) = [b 2]
[a 1] [b 2] [b 2] [c 3] [x 24]
insert(begin(), [L'y' 25]) = [y 25]
[a 1] [b 2] [b 2] [c 3] [x 24] [y 25]
[a 1] [b 2] [b 2] [c 3] [x 24]
[a 1] [b 2] [b 2] [c 3] [x 24] [y 25]

hash_multimap:: iterator (STL/CLR) hash_multimap::iterator (STL/CLR)

受控序列的迭代器的类型。The type of an iterator for the controlled sequence.

语法Syntax

typedef T1 iterator;

备注Remarks

该类型描述 T1 可用作受控序列的双向迭代器的未指定类型的对象。The type describes an object of unspecified type T1 that can serve as a bidirectional iterator for the controlled sequence.

示例Example

// cliext_hash_multimap_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    Myhash_multimap::iterator it = c1.begin();
    for (; it != c1.end(); ++it)
        System::Console::Write("[{0} {1}] ", it->first, it->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

hash_multimap:: key_comp (STL/CLR) hash_multimap::key_comp (STL/CLR)

复制两个键的排序委托。Copies the ordering delegate for two keys.

语法Syntax

key_compare^key_comp();

备注Remarks

此成员函数返回用于对受控序列进行排序的排序委托。The member function returns the ordering delegate used to order the controlled sequence. 用于对两个键进行比较。You use it to compare two keys.

示例Example

// cliext_hash_multimap_key_comp.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    Myhash_multimap::key_compare^ kcomp = c1.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    System::Console::WriteLine();

    // test a different ordering rule
    Myhash_multimap c2 = cliext::greater<wchar_t>();
    kcomp = c2.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    return (0);
    }
compare(L'a', L'a') = True
compare(L'a', L'b') = True
compare(L'b', L'a') = False

compare(L'a', L'a') = False
compare(L'a', L'b') = False
compare(L'b', L'a') = True

hash_multimap:: key_compare (STL/CLR) hash_multimap::key_compare (STL/CLR)

两个键的排序委托。The ordering delegate for two keys.

语法Syntax

Microsoft::VisualC::StlClr::BinaryDelegate<GKey, GKey, bool>
    key_compare;

备注Remarks

类型是委托的同义词,它确定其密钥参数的顺序。The type is a synonym for the delegate that determines the ordering of its key arguments.

示例Example

// cliext_hash_multimap_key_compare.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    Myhash_multimap::key_compare^ kcomp = c1.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    System::Console::WriteLine();

    // test a different ordering rule
    Myhash_multimap c2 = cliext::greater<wchar_t>();
    kcomp = c2.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    return (0);
    }
compare(L'a', L'a') = True
compare(L'a', L'b') = True
compare(L'b', L'a') = False

compare(L'a', L'a') = False
compare(L'a', L'b') = False
compare(L'b', L'a') = True

hash_multimap:: key_type (STL/CLR) hash_multimap::key_type (STL/CLR)

排序键的类型。The type of an ordering key.

语法Syntax

typedef Key key_type;

备注Remarks

该类型是模板参数 的同义词。The type is a synonym for the template parameter Key.

示例Example

// cliext_hash_multimap_key_type.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]" using key_type
    for (Myhash_multimap::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in key_type object
        Myhash_multimap::key_type val = it->first;

        System::Console::Write("{0} ", val);
        }
    System::Console::WriteLine();
    return (0);
    }
a b c

hash_multimap:: load_factor (STL/CLR) hash_multimap::load_factor (STL/CLR)

对每个存储桶的平均元素数进行计数。Counts the average elements per bucket.

语法Syntax

float load_factor();

备注Remarks

此成员函数返回 (float) hash_multimap:: size (stl/clr) () / hash_multimap:: bucket_count (stl/clr) ()The member function returns (float)hash_multimap::size (STL/CLR)() / hash_multimap::bucket_count (STL/CLR)(). 使用它来确定平均存储桶大小。You use it to determine the average bucket size.

示例Example

// cliext_hash_multimap_load_factor.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1 = gcnew Myhash_multimap;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect current parameters
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // change max_load_factor and redisplay
    c1.max_load_factor(0.25f);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // rehash and redisplay
    c1.rehash(100);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    return (0);
    }
[a 1] [b 2] [c 3]
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4

bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25

bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25

hash_multimap:: lower_bound (STL/CLR) hash_multimap::lower_bound (STL/CLR)

查找与指定键匹配的范围的开头。Finds beginning of range that matches a specified key.

语法Syntax

iterator lower_bound(key_type key);

parametersParameters

keykey
要搜索的键值。Key value to search for.

备注Remarks

成员函数确定受控序列中的第一个元素 X ,该元素将哈希处理为与 相同的存储桶并具有与 等效的排序。The member function determines the first element X in the controlled sequence that hashes to the same bucket as key and has equivalent ordering to key. 如果此类元素不存在,它将返回hash_multimap:: end (STL/CLR) () ; 否则,它将返回指定的迭代器 XIf no such element exists, it returns hash_multimap::end (STL/CLR)(); otherwise it returns an iterator that designates X. 用于查找当前在受控序列中与指定键匹配的一系列元素的开头。You use it to locate the beginning of a sequence of elements currently in the controlled sequence that match a specified key.

示例Example

// cliext_hash_multimap_lower_bound.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("lower_bound(L'x')==end() = {0}",
        c1.lower_bound(L'x') == c1.end());

    Myhash_multimap::iterator it = c1.lower_bound(L'a');
    System::Console::WriteLine("*lower_bound(L'a') = [{0} {1}]",
        it->first, it->second);
    it = c1.lower_bound(L'b');
    System::Console::WriteLine("*lower_bound(L'b') = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
lower_bound(L'x')==end() = True
*lower_bound(L'a') = [a 1]
*lower_bound(L'b') = [b 2]

hash_multimap:: make_value (STL/CLR) hash_multimap::make_value (STL/CLR)

构造一个值对象。Constructs a value object.

语法Syntax

static value_type make_value(key_type key, mapped_type mapped);

parametersParameters

keykey
要使用的密钥值。Key value to use.

已映射mapped
要搜索的映射值。Mapped value to search for.

备注Remarks

成员函数返回一个 value_type 对象,其键为 key ,并 映射 其映射值。The member function returns a value_type object whose key is key and whose mapped value is mapped. 使用它来编写适用于多个其他成员函数的对象。You use it to compose an object suitable for use with several other member functions.

示例Example

// cliext_hash_multimap_make_value.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

hash_multimap:: mapped_type (STL/CLR) hash_multimap::mapped_type (STL/CLR)

与每个键关联的映射值的类型。The type of a mapped value associated with each key.

语法Syntax

typedef Mapped mapped_type;

备注Remarks

类型是 映射 的模板参数的同义词。The type is a synonym for the template parameter Mapped.

示例Example

// cliext_hash_multimap_mapped_type.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]" using mapped_type
    for (Myhash_multimap::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in mapped_type object
        Myhash_multimap::mapped_type val = it->second;

        System::Console::Write("{0} ", val);
        }
    System::Console::WriteLine();
    return (0);
    }
1 2 3

hash_multimap:: max_load_factor (STL/CLR) hash_multimap::max_load_factor (STL/CLR)

获取或设置每个存储桶的最多元素数。Gets or sets the maximum elements per bucket.

语法Syntax

float max_load_factor();
void max_load_factor(float new_factor);

parametersParameters

new_factornew_factor
要存储的新的最大加载因子。New maximum load factor to store.

备注Remarks

第一个成员函数将返回当前存储的最大加载因子。The first member function returns the current stored maximum load factor. 使用它来确定最大平均存储桶大小。You use it to determine the maximum average bucket size.

第二个成员函数将存储最大加载因子替换 new_factorThe second member function replaces the store maximum load factor with new_factor. 在后续插入之前,不会自动 rehashing。No automatic rehashing occurs until a subsequent insert.

示例Example

// cliext_hash_multimap_max_load_factor.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1 = gcnew Myhash_multimap;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect current parameters
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // change max_load_factor and redisplay
    c1.max_load_factor(0.25f);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // rehash and redisplay
    c1.rehash(100);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    return (0);
    }
[a 1] [b 2] [c 3]
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4

bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25

bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25

hash_multimap:: operator = (STL/CLR) hash_multimap::operator= (STL/CLR)

替换受控序列。Replaces the controlled sequence.

语法Syntax

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

parametersParameters

然后right
用于复制的容器。Container to copy.

备注Remarks

成员运算符 直接 复制到对象,然后返回 *thisThe member operator copies right to the object, then returns *this. 用于将受控序列替换为 右侧 受控序列的副本。You use it to replace the controlled sequence with a copy of the controlled sequence in right.

示例Example

// cliext_hash_multimap_operator_as.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // assign to a new container
    Myhash_multimap c2;
    c2 = c1;
// display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]

hash_multimap:: rbegin (STL/CLR) hash_multimap::rbegin (STL/CLR)

指定反向受控序列的开头。Designates the beginning of the reversed controlled sequence.

语法Syntax

reverse_iterator rbegin();

备注Remarks

成员函数返回一个反向迭代器,该迭代器指定受控序列的最后一个元素,或刚超出空序列的开头。The member function returns a reverse iterator that designates the last element of the controlled sequence, or just beyond the beginning of an empty sequence. 因此,它指定反向序列的 beginningHence, it designates the beginning of the reverse sequence. 用于获取一个迭代器,该迭代器指定相反顺序的受控序列的 current 开头,但如果受控序列的长度发生更改,则该迭代器的状态也会发生更改。You use it to obtain an iterator that designates the current beginning of the controlled sequence seen in reverse order, but its status can change if the length of the controlled sequence changes.

示例Example

// cliext_hash_multimap_rbegin.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect first two items in reversed sequence
    Myhash_multimap::reverse_iterator rit = c1.rbegin();
    System::Console::WriteLine("*rbegin() = [{0} {1}]",
        rit->first, rit->second);
    ++rit;
    System::Console::WriteLine("*++rbegin() = [{0} {1}]",
        rit->first, rit->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*rbegin() = [c 3]
*++rbegin() = [b 2]

hash_multimap:: reference (STL/CLR) hash_multimap::reference (STL/CLR)

元素的引用的类型。The type of a reference to an element.

语法Syntax

typedef value_type% reference;

备注Remarks

类型描述对元素的引用。The type describes a reference to an element.

示例Example

// cliext_hash_multimap_reference.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    Myhash_multimap::iterator it = c1.begin();
    for (; it != c1.end(); ++it)
        {   // get a reference to an element
        Myhash_multimap::reference ref = *it;
        System::Console::Write("[{0} {1}] ", ref->first, ref->second);
        }
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

hash_multimap:: rehash (STL/CLR) hash_multimap::rehash (STL/CLR)

重新生成哈希表。Rebuilds the hash table.

语法Syntax

void rehash();

备注Remarks

此成员函数重新生成哈希表,确保hash_multimap:: load_factor (stl/clr) () <= hash_multimap:: max_load_factor (STL/clr) The member function rebuilds the hash table, ensuring that hash_multimap::load_factor (STL/CLR)() <= hash_multimap::max_load_factor (STL/CLR). 否则,只有在插入后才需要哈希表的大小。Otherwise, the hash table increases in size only as needed after an insertion. (不会自动降低大小。 ) 用于调整哈希表的大小。(It never automatically decreases in size.) You use it to adjust the size of the hash table.

示例Example

// cliext_hash_multimap_rehash.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1 = gcnew Myhash_multimap;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect current parameters
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // change max_load_factor and redisplay
    c1.max_load_factor(0.25f);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // rehash and redisplay
    c1.rehash(100);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    return (0);
    }
[a 1] [b 2] [c 3]
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4

bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25

bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25

hash_multimap:: rend (STL/CLR) hash_multimap::rend (STL/CLR)

指定反向受控序列的末尾。Designates the end of the reversed controlled sequence.

语法Syntax

reverse_iterator rend();

备注Remarks

成员函数返回一个反向迭代器,该迭代器指向刚刚超出受控序列的开头。The member function returns a reverse iterator that points just beyond the beginning of the controlled sequence. 因此,它指定反向序列的 endHence, it designates the end of the reverse sequence. 用于获取一个迭代器,该迭代器指定相反顺序的受控序列的 current 末尾,但如果受控序列的长度发生更改,则该迭代器的状态也会发生更改。You use it to obtain an iterator that designates the current end of the controlled sequence seen in reverse order, but its status can change if the length of the controlled sequence changes.

示例Example

// cliext_hash_multimap_rend.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect first two items in reversed sequence
    Myhash_multimap::reverse_iterator rit = c1.rend();
    --rit;
    --rit;
    System::Console::WriteLine("*-- --rend() = [{0} {1}]",
        rit->first, rit->second);
    ++rit;
    System::Console::WriteLine("*--rend() = [{0} {1}]",
        rit->first, rit->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*-- --rend() = [b 2]
*--rend() = [a 1]

hash_multimap:: reverse_iterator (STL/CLR) hash_multimap::reverse_iterator (STL/CLR)

受控序列的反向迭代器的类型。The type of a reverse iterator for the controlled sequence.

语法Syntax

typedef T3 reverse_iterator;

备注Remarks

该类型描述了可充当受控序列的反向迭代器的未指定类型 T3 的对象。The type describes an object of unspecified type T3 that can serve as a reverse iterator for the controlled sequence.

示例Example

// cliext_hash_multimap_reverse_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]" reversed
    Myhash_multimap::reverse_iterator rit = c1.rbegin();
    for (; rit != c1.rend(); ++rit)
        System::Console::Write("[{0} {1}] ", rit->first, rit->second);
    System::Console::WriteLine();
    return (0);
    }
[c 3] [b 2] [a 1]

hash_multimap:: size (STL/CLR) hash_multimap::size (STL/CLR)

对元素数进行计数。Counts the number of elements.

语法Syntax

size_type size();

备注Remarks

成员函数将返回受控序列的长度。The member function returns the length of the controlled sequence. 用于确定受控序列中当前的元素数。You use it to determine the number of elements currently in the controlled sequence. 如果你只关心序列的大小是否为非零,请参阅hash_multimap:: empty (STL/CLR) ()If all you care about is whether the sequence has nonzero size, see hash_multimap::empty (STL/CLR)().

示例Example

// cliext_hash_multimap_size.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0} after clearing", c1.size());

    // add elements and clear again
    c1.insert(Myhash_multimap::make_value(L'd', 4));
    c1.insert(Myhash_multimap::make_value(L'e', 5));
    System::Console::WriteLine("size() = {0} after adding 2", c1.size());
    return (0);
    }
[a 1] [b 2] [c 3]
size() = 0 after clearing
size() = 2 after adding 2

hash_multimap:: size_type (STL/CLR) hash_multimap::size_type (STL/CLR)

两个元素间的带符号距离的类型。The type of a signed distance between two element.

语法Syntax

typedef int size_type;

备注Remarks

该类型描述了一个非负元素计数。The type describes a non-negative element count.

示例Example

// cliext_hash_multimap_size_type.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // compute positive difference
    Myhash_multimap::size_type diff = 0;
    for (Myhash_multimap::iterator it = c1.begin(); it != c1.end(); ++it)
        ++diff;
    System::Console::WriteLine("end()-begin() = {0}", diff);
    return (0);
    }
[a 1] [b 2] [c 3]
end()-begin() = 3

hash_multimap:: swap (STL/CLR) hash_multimap::swap (STL/CLR)

交换两个容器的内容。Swaps the contents of two containers.

语法Syntax

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

parametersParameters

然后right
要与其交换内容的容器。Container to swap contents with.

备注Remarks

成员函数交换和右之间的受控 this 序列。The member function swaps the controlled sequences between this and right. 它在固定时间内执行此操作,并且不会引发异常。It does so in constant time and it throws no exceptions. 使用该方法可以快速交换两个容器的内容。You use it as a quick way to exchange the contents of two containers.

示例Example

// cliext_hash_multimap_swap.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct another container with repetition of values
    Myhash_multimap c2;
    c2.insert(Myhash_multimap::make_value(L'd', 4));
    c2.insert(Myhash_multimap::make_value(L'e', 5));
    c2.insert(Myhash_multimap::make_value(L'f', 6));
    for each (Myhash_multimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // swap and redisplay
    c1.swap(c2);
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    for each (Myhash_multimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[d 4] [e 5] [f 6]
[d 4] [e 5] [f 6]
[a 1] [b 2] [c 3]

hash_multimap:: to_array (STL/CLR) hash_multimap::to_array (STL/CLR)

将受控序列复制到新数组。Copies the controlled sequence to a new array.

语法Syntax

cli::array<value_type>^ to_array();

备注Remarks

此成员函数返回包含受控序列的数组。The member function returns an array containing the controlled sequence. 可以使用它以数组形式获取受控序列的副本。You use it to obtain a copy of the controlled sequence in array form.

示例Example

// cliext_hash_multimap_to_array.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // copy the container and modify it
    cli::array<Myhash_multimap::value_type>^ a1 = c1.to_array();

    c1.insert(Myhash_multimap::make_value(L'd', 4));
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // display the earlier array copy
    for each (Myhash_multimap::value_type elem in a1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3] [d 4]
[a 1] [b 2] [c 3]

hash_multimap:: upper_bound (STL/CLR) hash_multimap::upper_bound (STL/CLR)

查找与指定键匹配的范围的末尾。Finds end of range that matches a specified key.

语法Syntax

iterator upper_bound(key_type key);

parametersParameters

keykey
要搜索的键值。Key value to search for.

备注Remarks

成员函数确定受控序列中的最后一个元素 X ,该元素将哈希处理为与 相同的存储桶并具有与 等效的排序。The member function determines the last element X in the controlled sequence that hashes to the same bucket as key and has equivalent ordering to key. 如果此类元素不存在,或 X 为受控序列中的最后一个元素,则它将返回hash_multimap:: END (STL/CLR) () ; 否则,它将返回一个指定第一个元素的迭代器 XIf no such element exists, or if X is the last element in the controlled sequence, it returns hash_multimap::end (STL/CLR)(); otherwise it returns an iterator that designates the first element beyond X. 使用它可以查找受控序列中当前与指定键匹配的元素序列的末尾。You use it to locate the end of a sequence of elements currently in the controlled sequence that match a specified key.

示例Example

// cliext_hash_multimap_upper_bound.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_multimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("upper_bound(L'x')==end() = {0}",
        c1.upper_bound(L'x') == c1.end());

    Myhash_multimap::iterator it = c1.upper_bound(L'a');
    System::Console::WriteLine("*upper_bound(L'a') = [{0} {1}]",
        it->first, it->second);
    it = c1.upper_bound(L'b');
    System::Console::WriteLine("*upper_bound(L'b') = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
upper_bound(L'x')==end() = True
*upper_bound(L'a') = [b 2]
*upper_bound(L'b') = [c 3]

hash_multimap:: value_comp (STL/CLR) hash_multimap::value_comp (STL/CLR)

复制两个元素值的排序委托。Copies the ordering delegate for two element values.

语法Syntax

value_compare^ value_comp();

备注Remarks

此成员函数返回用于对受控序列进行排序的排序委托。The member function returns the ordering delegate used to order the controlled sequence. 用于比较两个元素值。You use it to compare two element values.

示例Example

// cliext_hash_multimap_value_comp.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    Myhash_multimap::value_compare^ kcomp = c1.value_comp();

    System::Console::WriteLine("compare([L'a', 1], [L'a', 1]) = {0}",
        kcomp(Myhash_multimap::make_value(L'a', 1),
            Myhash_multimap::make_value(L'a', 1)));
    System::Console::WriteLine("compare([L'a', 1], [L'b', 2]) = {0}",
        kcomp(Myhash_multimap::make_value(L'a', 1),
            Myhash_multimap::make_value(L'b', 2)));
    System::Console::WriteLine("compare([L'b', 2], [L'a', 1]) = {0}",
        kcomp(Myhash_multimap::make_value(L'b', 2),
            Myhash_multimap::make_value(L'a', 1)));
    System::Console::WriteLine();
    return (0);
    }
compare([L'a', 1], [L'a', 1]) = True
compare([L'a', 1], [L'b', 2]) = True
compare([L'b', 2], [L'a', 1]) = False

hash_multimap:: value_compare (STL/CLR) hash_multimap::value_compare (STL/CLR)

两个元素值的排序委托。The ordering delegate for two element values.

语法Syntax

Microsoft::VisualC::StlClr::BinaryDelegate<generic_value, generic_value, bool>
    value_compare;

备注Remarks

类型是委托的同义词,用于确定其值参数的顺序。The type is a synonym for the delegate that determines the ordering of its value arguments.

示例Example

// cliext_hash_multimap_value_compare.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    Myhash_multimap::value_compare^ kcomp = c1.value_comp();

    System::Console::WriteLine("compare([L'a', 1], [L'a', 1]) = {0}",
        kcomp(Myhash_multimap::make_value(L'a', 1),
            Myhash_multimap::make_value(L'a', 1)));
    System::Console::WriteLine("compare([L'a', 1], [L'b', 2]) = {0}",
        kcomp(Myhash_multimap::make_value(L'a', 1),
            Myhash_multimap::make_value(L'b', 2)));
    System::Console::WriteLine("compare([L'b', 2], [L'a', 1]) = {0}",
        kcomp(Myhash_multimap::make_value(L'b', 2),
            Myhash_multimap::make_value(L'a', 1)));
    System::Console::WriteLine();
    return (0);
    }
compare([L'a', 1], [L'a', 1]) = True
compare([L'a', 1], [L'b', 2]) = True
compare([L'b', 2], [L'a', 1]) = False

hash_multimap:: value_type (STL/CLR) hash_multimap::value_type (STL/CLR)

元素的类型。The type of an element.

语法Syntax

typedef generic_value value_type;

备注Remarks

该类型是 generic_value 的同义词。The type is a synonym for generic_value.

示例Example

// cliext_hash_multimap_value_type.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;
int main()
    {
    Myhash_multimap c1;
    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));

    // display contents " [a 1] [b 2] [c 3]" using value_type
    for (Myhash_multimap::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in value_type object
        Myhash_multimap::value_type val = *it;
        System::Console::Write("[{0} {1}] ", val->first, val->second);
        }
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]