xtd 0.2.0
Loading...
Searching...
No Matches

◆ reserve()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual void xtd::collections::generic::list< type_t, allocator_t >::reserve ( size_type  new_cap)
inlinevirtual

Increase the capacity of the vector (the total number of elements that the vector can hold without requiring reallocation) to a value that's greater or equal to new_cap. If new_cap is greater than the current capacity(), new storage is allocated, otherwise the function does nothing.

Parameters
new_capThe new capacity of the vector, in number of elements.
Remarks
xtd::collections::generic::list::reserve does not change the size of the vector.
If new_cap is greater than xtd::collections::generic::list::capacity property, all iterators, including the xtd::collections::generic::list::end iterator, and all references to the elements are invalidated; otherwise, no iterators or references are invalidated.
After a call to xtd::collections::generic::list::reserve, insertions will not trigger reallocation unless the insertion would make the size of the vector greater than the value of xtd::collections::generic::list::capacity.