vector的一些操作

来源:互联网 发布:晃然学姐的淘宝店 编辑:程序博客网 时间:2024/06/05 18:17

做题的时候,碰到vector的一些函数,特此记下来。

1.reserve(n): Requests that the vector capacity be at least enough to contain n elements

2.lower_bound

1)lower_bound (ForwardIterator first, ForwardIterator last,                               const T& val);
2)lower_bound (ForwardIterator first, ForwardIterator last,                               const T& val, Compare comp);
Returns an iterator pointing to the first element in the range [first,last) which does not compare less than val.

3.upper_bound

1)upper_bound (ForwardIterator first, ForwardIterator last,                               const T& val);
2)upper_bound (ForwardIterator first, ForwardIterator last,
                               const T& val, Compare comp);
Returns an iterator pointing to the first element in the range [first,last) which compares greater than val.
4.insert
void insert (iterator position, InputIterator first, InputIterator last);
position开始,插入[first, last)的元素

0 0