Концепции C++: SequenceContainer
Материал из 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. |
SequenceContainer является Container который хранит объекты того же типа в линейном расположении.Original:
A
SequenceContainer is a Container that stores objects of the same type in a linear arrangement.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: Legend The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
X
|
Тип контейнера
Original: Container type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
T
|
Тип элемента
Original: Element type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
a, b
|
Объекты типа
XOriginal: Objects of type XThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
t
|
Объект типа
T Original: Object of type T The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
n
|
Положительное целое число
Original: Positive integer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
i, j
|
InputIterators обозначающих допустимый диапазонOriginal: InputIterators denoting a valid rangeThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
il
|
std::initializer_list<T> |
args
|
Параметр пакета
Original: Parameter pack The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
p, q
|
const_iterators в
a Original: const_iterators in a The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| expression | return type | effects | precondition | postcondition |
|---|---|---|---|---|
| X(n,t) | Constructs a SequenceContainer containing n copies of t |
T CopyInsertable |
std::distance(begin(),end()) == n | |
| X(i,j) | Constructs a SequenceContainer equivalent to the range [i,j)
|
|
std::distance(begin(),end()) == std::distance(i,j) | |
| X(il) | X(il.begin(),il.end) | |||
| a = il | X& | Assigns the range represented by il into a
|
T CopyInsertable and CopyAssignable
|
Existing elements of a are destroyed or assigned to
|
| a.emplace(p,args) | iterator | Insert an object constructed with std::forward<Args>(args) before p
|
|
|
| a.emplace(p,t) | iterator | Inserts a copy of t before i
|
|
|
| a.insert(p,n,t) | iterator | Inserts n copies of t before i
|
T CopyInsertable and CopyAssignable
|
|
| a.insert(p,i,j) | iterator | Inserts copies of elements in [i, j) before p
|
|
Each iterator in [i,j) is dereferenced once
|
| a.insert(p, il) | iterator | a.insert(p,il.begin(),il.end()) | ||
| a.erase(q) | iterator | Erases the element pointed to by q | (зЬй :: дека, STD :: вектор) T MoveAssignable
|
|
| a.erase(p,q) | iterator | Erases elements in [p,q) |
(зЬй :: дека, STD :: вектор) T MoveAssignable |
|
| a.clear() | void | Destroys all elements in a |
| |
| a.assign(i,j) | void | Replaces elements in a with a copy of [i, j)
|
|
Each iterator in [i,j) is dereferenced once
|
| a.assign(il) | void | a.assign(il.begin(),il.end()) | ||
| a.assign(n,t) | void | Replaces elements in a with n copies of t
|
T CopyInsertable and CopyAssignable
|
[править] Дополнительные операции
| Этот раздел не завершён |
[править] SequenceContainers в стандартной библиотеке
| (начиная с C++11) |
статического непрерывный массив Original: static contiguous array The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) |
| динамический непрерывный массив Original: dynamic contiguous array The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) | |
| Двусторонний очереди Original: double-ended queue The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) | |
| (начиная с C++11) |
односвязный список Original: singly-linked list The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) |
| дважды связанный список Original: doubly-linked list The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) | |
[править] Компромиссы / использование заметок
| std::array | Быстрый доступ, но фиксированное число элементов
Original: Fast access but fixed 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. |
| std::vector | Быстрый доступ, но в основном неэффективной вставок / удалений
Original: Fast access but mostly inefficient insertions/deletions The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| std::list std::forward_list |
Эффективное вставки / удаления в середине последовательности
Original: Efficient insertion/deletion in the middle of the sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| std::deque | Эффективное вставки / удаления в начале и в конце последовательности
Original: Efficient insertion/deletion at the beginning and at the end of the sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |