C 什么是map
发布网友
发布时间:2022-05-20 13:07
我来回答
共1个回答
热心网友
时间:2023-10-24 02:38
map 是一种容器,容纳一些数据。而且这些数据可以有索引键Key,通过这些索引键,可以查到值。
MSDN中如是说:
The STL map class is:
An associative container, which a variable size container that supports the efficient retrieval of element values based on an associated key value.
Reversible, because it provides bidirectional iterators to access its elements.
Sorted, because its elements are ordered by key values within the container in accordance with a specified comparison function.
Unique in the sense that each of its elements must have a unique key.
A pair associative container, because its element data values are distinct from its key values.
A template class, because the functionality it provides is generic and so independent of the specific type of data contained as elements or keys. The data types to be used for elements and keys are, instead, specified as parameters in the class template along with the comparison function and allocator.
参考资料:MSDN