stl中map函数_map :: max_size()函数,以及C ++ STL中的Example
stl中map函數(shù)
C ++ STL映射:: max_size() (C++ STL map::max_size() )
It returns the maximum number of elements the container(map) is able to hold but at runtime, the size of the container may be limited to a value smaller than specified by max_size() by the amount of RAM available. It gives us an only a theoretical limit on the size of the container.
它返回容器(映射)能夠容納的最大元素數(shù)量,但是在運(yùn)行時,容器的大小可能會限制為小于可用max_size()指定的可用RAM數(shù)量的值。 它僅對容器的大小提供了理論上的限制。
Syntax:
句法:
myMap.max_size()Where, myMap is the object of class map.
其中, myMap是類映射的對象。
Parameters: None - It does not accept any parameters.
參數(shù):無-不接受任何參數(shù)。
Return value: It simply returns the maximum number of elements container can hold.
返回值:它僅返回容器可以容納的最大元素數(shù)。
Example:
例:
#include <bits/stdc++.h> using namespace std; int main() { // create map container map<int, int> myMap;//insert an element in mapmyMap.insert( pair<int, int>(200 , 100) ); cout<<"max size of Non-empty map : \n"; cout << "The max size of myMap is " << myMap.max_size();map<char,char> EmpMap;map<int, int> EmpMap2; cout<<"max size of Empty-map : \n"; cout << "\nThe max size of EmpMap is " << EmpMap.max_size();cout << "\nThe max size of EmpMap2 is " << EmpMap2.max_size();return 0; }Output
輸出量
max size of Non-empty map : The max size of myMap is 461168601842738790max size of Empty-map :The max size of EmpMap is 461168601842738790 The max size of EmpMap2 is 461168601842738790翻譯自: https://www.includehelp.com/stl/map-max-size-function-with-example-in-cpp-stl.aspx
stl中map函數(shù)
總結(jié)
以上是生活随笔為你收集整理的stl中map函数_map :: max_size()函数,以及C ++ STL中的Example的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux重定向命令是干嘛的,Linux
- 下一篇: g++默认参数_C ++默认参数| 查找