Function set_capacity


#include <include/EASTL/deque.h>

void set_capacity(size_type n=base_type::npos)


No description yet.


Lines 1491-1512 in include/EASTL/deque.h. Line 422 in include/EASTL/deque.h.

template <typename T, typename Allocator, unsigned kDequeSubarraySize>
inline void deque<T, Allocator, kDequeSubarraySize>::set_capacity(size_type n)
    // Currently there isn't a way to remove all allocations from a deque, as it 
    // requires a single starting allocation for the subarrays. So we can't just
    // free all memory without leaving it in a bad state. So the best means of 
    // implementing set_capacity() is to do what we do below.
    if(n == 0)
        this_type temp(mAllocator);
    else if(n < size())
        // We currently ignore the request to reduce capacity. To do: Implement this
        // and do it in a way that doesn't result in temporarily ~doubling our memory usage.
        // That might involve trimming unused subarrays from the front or back of 
        // the container.

Add Discussion as Guest

Log in