好长时间没有写博客了,重新开始写又有一点不一样的感觉,有点怅然若失,或者说是又有点小期待,一直以来状态不是很好,但不管如何还是要坚强地、勇敢地走下去。
言归正传
C++中vector是一项大杀器,相当于可自动变长的数组,在不改变容量的情况下,其效率相当于数组,但较于数组而言他又有更多的优点,首先介绍几个成员函数与vector容量相关的
- size() Returns the number of elements in the vector This is the number of actual objects held in the vector, which is not necessarily equal to its storage capacity.(即返回元素个数)
- capacity()The size of the currently allocated storage capacity in the vector, measured in terms of the number elements it can hold.