概述STL

使用stl可以大大提高算法设计的效率和可靠性。

More
stlvector

Vectors are same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted, with their storage being handled automatically by the container. Vector elements are placed in contiguous storage so that they can be accessed and traversed using iterators. In vectors, data is inserted at the end. Inserting at the end takes differential time, as sometimes there may be a need of extending the array. Removing the last element takes only constant time because no resizing happens. Inserting and erasing at the beginning or in the middle is linear in time.

向量与动态数组相同,具有在插入或删除元素时自动调整自身大小的能力,并且容器自动处理其存储。 矢量元素放置在连续的存储中,以便可以使用迭代器对其进行访问和遍历。 在向量中,数据插入到最后(push_back())。 在末尾插入需要花费不同的时间,因为有时可能需要扩展阵列。 删除最后一个元素只需要固定的时间,因为不会发生大小调整。 在开始或中间插入和擦除的时间是线性的。

More

本站文章使用 CC BY-NC-SA 4.0 许可证