现在的位置: 首页 > 综合 > 正文

vector.resize

2018年12月13日 ⁄ 综合 ⁄ 共 541字 ⁄ 字号 评论关闭

void resize ( size_type sz, T c = T() );
Change size

Resizes the vector to contain sz elements.

If sz is smaller than the current vector size, the content is reduced to its first sz elements, the rest being dropped.

If sz is greater than the current vector size, the content is expanded by inserting at the end as many copies of c as needed to reach a size of sz elements.
This may cause a reallocation.

Notice that this function changes the actual content of the vector by inserting or erasing elements from the vector; It does not only change its storage capacity.
To direct a change only in storage capacity, use vector::reserveinstead.

【上篇】
【下篇】

抱歉!评论已关闭.