public member function
<deque>
std::deque::shrink_to_fitShrink to fit
Requests the container to reduce its memory usage to fit its size.A deque container may have more memory allocated than needed to hold its current elements: this is because most libraries implement deque as a dynamic array that can keep the allocated space of removed elements or allocate additional capacity in advance to allow for faster insertion operations.
This function requests that the memory usage is adapted to the current size of the container, but the request is non-binding, and the container implementation is free to optimize its memory usage otherwise.
Note that this function does not change the size of the container (for that, see resize instead).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// deque::shrink_to_fit
#include <iostream>
#include <deque>
int main ()
{
std::deque<int> mydeque (100);
std::cout << "1. size of mydeque: " << mydeque.size() << '\n';
mydeque.resize(10);
std::cout << "2. size of mydeque: " << mydeque.size() << '\n';
mydeque.shrink_to_fit();
return 0;
}
1. size of mydeque: 100 2. size of mydeque: 10
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4