deque max_size() function in C++ STL
Last Updated :
27 Jun, 2023
The deque::max_size() is a built-in function in C++ STL which returns the maximum number of elements that a deque container can hold.
Syntax:
deque_name.max_size()
Parameters: The function does not accept any parameters.
Return Value: The function returns the maximum number of elements that a deque container can hold.
Below programs illustrate the above function:
Program 1:
CPP
#include <bits/stdc++.h>
using namespace std;
int main()
{
deque< int > dq;
dq.push_back(1);
dq.push_back(10);
dq.push_back(100);
dq.push_back(50);
dq.push_back(40);
dq.push_back(23);
dq.push_back(6);
cout << "The deque elements: " ;
for ( auto it = dq.begin(); it != dq.end(); it++)
cout << *it << " " ;
cout << "\nThe max-size of deque: " << dq.max_size();
return 0;
}
|
Output
The deque elements: 1 10 100 50 40 23 6
The max-size of deque: 4611686018427387903
Program 2:
CPP
#include <bits/stdc++.h>
using namespace std;
int main()
{
deque< int > dq;
cout << "The max-size of deque: " << dq.max_size();
return 0;
}
|
Output
The max-size of deque: 4611686018427387903
Time complexity: O(1)
Auxiliary Space: O(1)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...