Пространства имён
Варианты
Действия

std::vector::insert

Материал из cppreference.com

 
 
 
std::vector
Член функций
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vector::vector
vector::~vector
vector::operator=
vector::assign
vector::get_allocator
Элемент доступа
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vector::at
vector::operator[]
vector::front
vector::back
vector::data(C++11)
Итераторы
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vector::begin
vector::cbegin

(C++11)
vector::end
vector::cend

(C++11)
vector::rbegin
vector::crbegin

(C++11)
vector::rend
vector::crend

(C++11)
Потенциала
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vector::empty
vector::size
vector::max_size
vector::reserve
vector::capacity
vector::shrink_to_fit(C++11)
Модификаторы
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vector::clear
vector::insert
vector::emplace(C++11)
vector::erase
vector::push_back
vector::emplace_back(C++11)
vector::pop_back
vector::resize
vector::swap
 
iterator insert( iterator pos, const T& value );
iterator insert( const_iterator pos, const T& value );
(1) (до C++11)
(начиная с C++11)
iterator insert( const_iterator pos, T&& value );
(2) (начиная с C++11)
void insert( iterator pos, size_type count, const T& value );
iterator insert( const_iterator pos, size_type count, const T& value );
(3) (до C++11)
(начиная с C++11)
template< class InputIt >

void insert( iterator pos, InputIt first, InputIt last);
template< class InputIt >

iterator insert( const_iterator pos, InputIt first, InputIt last );
(4) (до C++11)

(начиная с C++11)
iterator insert( const_iterator pos, std::initializer_list<T> ilist );
(5) (начиная с C++11)
Вставка элементов в указанной позиции в контейнере.
Original:
Inserts elements to specified position in the container.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1-2)
вставками value перед элементом, на который указывает pos
Original:
inserts value before the element pointed to by pos
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
вставками count копии value перед элементом, на который указывает pos
Original:
inserts count copies of the value before the element pointed to by pos
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
вставками элементов из диапазона [first, last) перед элементом, на который указывает pos
Original:
inserts elements from range [first, last) before the element pointed to by pos
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
вставками элементов из списка инициализации ilist.
Original:
inserts elements from initializer list ilist.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Causes reallocation if the new size() is greater than the old capacity().If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references after the added element are invalidated.

Содержание

[править] Параметры

pos -
Элемент, перед которым содержание будет вставлен
Original:
element before which the content will be inserted
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
value -
Значение элемента для вставки
Original:
element value to insert
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
first, last -
диапазон элементов вставить, не может быть итераторов в контейнер, для которого вставка называется
Original:
the range of elements to insert, can't be iterators into container for which insert is called
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ilist -
инициализатор список вставить значения из
Original:
initializer list to insert the values from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Требования, накладываемые на типы
-
InputIt должен соответствовать требованиям InputIterator.

[править] Возвращаемое значение

1-2)
итератор, указывающий на вставленный value
Original:
iterator pointing to the inserted value
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
итератор, указывающий на первый элемент вставлен, или pos если count==0.
Original:
iterator pointing to the first element inserted, or pos if count==0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
итератор, указывающий на первый элемент вставлен, или pos если first==last.
Original:
iterator pointing to the first element inserted, or pos if first==last.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
итератор, указывающий на первый элемент вставлен, или pos если ilist пусто.
Original:
iterator pointing to the first element inserted, or pos if ilist is empty.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[править] Сложность

1-2) Constant plus linear in the distance between pos and end of the container.

3) Linear in count plus linear in the distance between pos and end of the container.

4) Linear in std::distance(first, last) plus linear in the distance between pos and end of the container.

5) Linear in ilist.size() plus linear in the distance between pos and end of the container.

[править] См. также

(C++11)
конструирует элемент "на месте"
(public функция-член) [edit]
добавляет элементы в конец
Original:
adds elements to the end
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(public функция-член) [edit]