stl中map函数_map :: max_size()函数,以及C ++ STL中的Example

stl中map函数

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.

它返回容器(映射)能够容纳的最大元素数量,但是在运行时,容器的大小可能会限制为小于可用max_size()指定的可用RAM数量的值。 它仅对容器的大小提供了理论上的限制。

Syntax:

句法:

    myMap.max_size()

Where, myMap is the object of class map.

其中, myMap是类映射的对象。

Parameters: None - It does not accept any parameters.

参数:无-不接受任何参数。

Return value: It simply returns the maximum number of elements container can hold.

返回值:它仅返回容器可以容纳的最大元素数。

Example:

例:

#include  
using namespace std; 

int main() 
{
       
	// create map container 
	map myMap;

	//insert an element in map
	myMap.insert( pair(200 , 100) ); 

	cout<<"max size of Non-empty map : \n"; 
	cout << "The max size of myMap is " << myMap.max_size();

	map EmpMap;
	map 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函数

你可能感兴趣的:(c++,java,python,javascript,深度学习)