vector.resize

来源:互联网 发布:u盘数据恢复大师 编辑:程序博客网 时间:2024/06/06 14:43
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.
原创粉丝点击