hash_map::const_iterator

说明说明

此 API 已过时。另一种方法是 unordered_map Class

提供了双向迭代器可以读取在 hash_map 的一个 const 元素的类型。

typedef list<typename Traits::value_type, typename Traits::allocator_type>::const_iterator const_iterator;

备注

类型 const_iterator 不能用于修改元素的值。

hash_map 定义的 const_iterator 指向是 value_type对象的元素,这是类型 pair*<const Key, Type>*,第一个成员是键的元素,第二个成员是元素占用的映射基线。

若要取消引用 const_iterator 指向在 hash_map 的元素的 cIter,请使用 -> 运算符。

访问键的值的元素,使用 cIter -> first,使用 (*cIter).first等效。访问映射基线值的元素的,使用 cIter -> second,使用 (*cIter).second等效。

在 Visual C++ .NET 2003 中,<hash_map><hash_set> 标头文件的成员中不再标准,命名空间,而是将 stdext 命名空间。有关更多信息,请参见 stdext 命名空间

示例

使用 const_iterator,有关示例的 启动 参见示例。

要求

标头: <hash_map>

命名空间: stdext

请参见

参考

hash_map Class

标准模板库