在C++中map容器是一个键值对容器,也就是一个Key对应一个Value,例如:(1,"hello),或者也可以是这样:("hello2",2),其中一个值为Key,第二个值为Value,在上面的例子中1和“hello2"是Key,当然它们对应的”hello"和2就是Value。
1、map定义在头文件<map>中,使用时要#include <map>;
2、声明时要使用类似这样的形式:map<int,string> testmap;或者map<stirng,string> testmap;等等。
3、map中支持的函数有:
Iterators:
-
begin
- Return iterator to beginning (public member function )
-
end
- Return iterator to end (public member function )
-
rbegin
- Return reverse iterator to reverse beginning (public member function )
-
rend
- Return reverse iterator to reverse end (public member function )
-
cbegin
- Return const_iterator to beginning (public member function )