std::deque
Материал из cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Заголовочный файл <deque>
|
||
| template< class T, |
||
std::deque (двусторонняя очередь) является индексированным контейнер последовательности, что позволяет быстро вставки и удаления в начале и в конце. Кроме того, вставки и удаления с обоих концов двусторонней очереди никогда недействительными указатели или ссылки на остальные элементы.Original:
std::deque (double-ended queue) is an indexed sequence container that allows fast insertion and deletion at both the beginning and the end. In addition, insertion and deletion at either end of a deque never invalidates pointers or references to the rest of the elements.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
В отличие от std::vector, элементы дека не хранятся непрерывно: от типичных реализаций использовать последовательность индивидуально выделены массивы фиксированного размера.
Original:
As opposed to std::vector, the elements of a deque are not stored contiguously: typical implementations use a sequence of individually allocated fixed-size arrays.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Хранение дека автоматически расширяется и контракты по мере необходимости. Расширение дека дешевле, чем расширение std::vector, потому что оно не связано с копированием существующих элементов в новую ячейку памяти.
Original:
The storage of the deque is automatically expanded and contracted as needed. Expansion of a deque is cheaper than the expansion of a std::vector because it does not involve copying of the existing elements to a new memory location.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Сложность (КПД) общей операции на двусторонних очередей выглядит следующим образом:
Original:
The complexity (efficiency) of common operations on deques is as follows:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- Произвольный доступ - постоянная O(1)Original:Random access - constant O(1)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Вставка и удаление элементов в начало или конец - амортизированной постоянной O(1)Original:Insertion or removal of elements at the end or beginning - amortized constant O(1)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Вставка и удаление элементов - линейные O(n)Original:Insertion or removal of elements - linear O(n)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::deque отвечает требованиям Container, AllocatorAwareContainer, SequenceContainer и ReversibleContainer.Original:
std::deque meets the requirements of Container, AllocatorAwareContainer, SequenceContainer and ReversibleContainer.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[править] Член типов
| Член типа
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
T
|
allocator_type
|
Allocator
|
size_type
|
Беззнаковый целочисленный тип (обычно size_t) |
difference_type
|
Знаковый целочисленный тип (обычно std::ptrdiff_t) |
reference
|
Allocator::reference (до C++11)value_type& (начиная с C++11)
|
const_reference
|
Allocator::const_reference (до C++11)const value_type& (начиная с C++11)
|
pointer
|
Allocator::pointer (до C++11)std::allocator_traits<Allocator>::pointer (начиная с C++11) |
const_pointer
|
Allocator::const_pointer (до C++11) std::allocator_traits<Allocator>::const_pointer (начиная с C++11) |
iterator
|
RandomAccessIterator
|
const_iterator
|
Константный итератор с произвольным доступом |
reverse_iterator
|
std::reverse_iterator<iterator> |
const_reverse_iterator
|
std::reverse_iterator<const_iterator> |
[править] Член функций
| строит deque Original: constructs the deque The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
destructs the deque (public функция-член) | |
| присваивает значения в контейнере Original: assigns values to the container The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| присваивает значения в контейнере Original: assigns values to the container The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| возвращает связанный распределителя Original: returns the associated allocator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
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. | |
| предоставляет доступ к указанному элементу с проверкой индекса (public функция-член) | |
| предоставляет доступ к указанному элементу (public функция-член) | |
| предоставляет доступ к первому элементу (public функция-член) | |
| предоставляет доступ к последнему элементу (public функция-член) | |
Original: Iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| возвращает итератор на первый элемент (public функция-член) | |
| возвращает итератор на элемент, следующий за последним (public функция-член) | |
| возвращает обратный итератор на начало Original: returns a reverse iterator to the beginning The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| возвращает обратный итератор до конца Original: returns a reverse iterator 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 функция-член) | |
Original: Capacity The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| проверяет отсутствие элементов в контейнере (public функция-член) | |
| возвращает количество элементов Original: returns the number of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| возвращает максимально допустимое количество элементов (public функция-член) | |
| (C++11) |
уменьшает использование памяти, освобождая неиспользуемую память Original: reduces memory usage by freeing unused memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) |
Original: Modifiers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| удаляет содержимое (public функция-член) | |
| вставки элементов Original: inserts elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| (C++11) |
конструирует элемент "на месте" (public функция-член) |
| удаляет элементы Original: erases elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| добавляет элементы в конец 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 функция-член) | |
| (C++11) |
Элементы конструкций на месте в конце Original: constructs elements in-place at 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 функция-член) |
| удаляет последний элемент Original: removes the last element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| вставляет элементы в начало списка (public функция-член) | |
| (C++11) |
конструирует элементы "на месте" в начало списка (public функция-член) |
| удаляет первый элемент (public функция-член) | |
| изменяет количество хранимых элементов (public функция-член) | |
| обмениевает содержимое (public функция-член) | |
[править] Не являющиеся членами функций
| лексикографически сравнивает значения в deque Original: lexicographically compares the values in the deque The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон функции) | |
| Специализируется std::swap алгоритм Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон функции) | |