Standard Template Library Programmer's Guide
Здесь есть возможность читать онлайн «Standard Template Library Programmer's Guide» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, Справочники, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.
- Название:Standard Template Library Programmer's Guide
- Автор:
- Жанр:
- Год:неизвестен
- ISBN:нет данных
- Рейтинг книги:4 / 5. Голосов: 1
-
Избранное:Добавить в избранное
- Отзывы:
-
Ваша оценка:
- 80
- 1
- 2
- 3
- 4
- 5
Standard Template Library Programmer's Guide: краткое содержание, описание и аннотация
Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Standard Template Library Programmer's Guide»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.
Standard Template Library Programmer's Guide — читать онлайн бесплатно полную книгу (весь текст) целиком
Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Standard Template Library Programmer's Guide», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
[2] Note that p equal to a.begin() means to insert something at the beginning of a (that is, before any elements already in a ), and p equal to a.end() means to append something to the end of a .
[3] Warning: there is no guarantee that a valid iterator on a is still valid after an insertion or an erasure. In some cases iterators do remain valid, and in other cases they do not. The details are different for each sequence class.
[4] a.insert(p, n, t) is guaranteed to be no slower then calling a.insert(p, t)n times. In some cases it is significantly faster.
[5] Vector is usually preferable to deque and list. Deque is useful in the case of frequent insertions at both the beginning and end of the sequence, and list and slist are useful in the case of frequent insertions in the middle of the sequence. In almost all other situations, vector is more efficient.
Container, Forward Container, Associative Container, Front Insertion Sequence, Back Insertion Sequence, vector , deque , list , slist
Front Insertion Sequence
Category: containers
Component type: concept
A Front Insertion Sequence is a Sequence where it is possible to insert an element at the beginning, or to access the first element, in amortized constant time. Front Insertion Sequences have special member functions as a shorthand for those operations.
Sequence
None, except for those of Sequence.
X
A type that is a model of Front Insertion Sequence
a
Object of type X
T
The value type of X
t
Object of type T
In addition to the expressions defined in Sequence, the following expressions must be valid.
Name | Expression | Type requirements | Return type |
---|---|---|---|
Front | a.front() [1] |
reference if a is mutable, otherwise const_reference . | |
Push front | a.push_front(t) |
a is mutable. | void |
Pop front | a.pop_front() |
a is mutable. | void |
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Front | a.front() [1] |
!a.empty() | Equivalent to *(a.begin()) . | |
Push front | a.push_front(t) | Equivalent to a.insert(a.begin(), t) a.size is incremented by 1. | a.front() is a copy of t . | |
Pop front | a.pop_front() |
!a.empty() |
Equivalent to a.erase(a.begin()) | a.size() is decremented by 1. |
Front, push front, and pop front are amortized constant time. [2]
Symmetry of push and pop | push_front() followed by pop_front() is a null operation. |
• list
• deque
[1] Front is actually defined in Sequence, since it is always possible to implement it in amortized constant time. Its definition is repeated here, along with push front and pop front, in the interest of clarity.
[2] This complexity guarantee is the only reason that front() , push_front() , and pop_front() are defined: they provide no additional functionality. Not every sequence must define these operations, but it is guaranteed that they are efficient if they exist at all.
Container, Sequence, Back Insertion Sequence, deque , list , slist
Back Insertion Sequence
Category: containers
Component type: concept
A Back Insertion Sequence is a Sequence where it is possible to append an element to the end, or to access the last element, in amortized constant time. Back Insertion Sequences have special member functions as a shorthand for those operations.
Sequence
None, except for those of Sequence.
X
A type that is a model of Back Insertion Sequence
a
Object of type X
T
The value type of X
t
Object of type T
In addition to the expressions defined in Sequence, the following expressions must be valid.
Name | Expression | Type requirements | Return type |
---|---|---|---|
Back | a.back() |
reference if a is mutable, otherwise const_reference . | |
Push back | a.push_back(t) |
a is mutable. | void |
Pop back | a.pop_back() |
a is mutable. | void |
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Back | a.back() |
!a.empty() |
Equivalent to *(--a.end()) . | |
Push back | a.push_back(t) |
Equivalent to a.insert(a.end(), t) a.size is incremented by 1. | a.back() is a copy of t . | |
Pop back | a.pop_back() |
!a.empty() |
Equivalent to a.erase(--a.end()) | a.size() is decremented by 1. |
Back, push back, and pop back are amortized constant time. [1]
Symmetry of push and pop | push_back() followed by pop_back() is a null operation. |
vector
list
deque
[1] This complexity guarantee is the only reason that back() , push_back() , and pop_back() are defined: they provide no additional functionality. Not every sequence must define these operations, but it is guaranteed that they are efficient if they exist at all.
Container, Sequence, Front Insertion Sequence, vector , deque , list
Associative Containers
Associative Container
Category: containers
Component type: concept
An Associative Container is a variable-sized Container that supports efficient retrieval of elements (values) based on keys. It supports insertion and removal of elements, but differs from a Sequence in that it does not provide a mechanism for inserting an element at a specific position. [1]
As with all containers, the elements in an Associative Container are of type value_type . Additionally, each element in an Associative Container has a key , of type key_type . In some Associative Containers, Simple Associative Containers, the value_type and key_type are the same: elements are their own keys. In others, the key is some specific part of the value. Since elements are stored according to their keys, it is essential that the key associated with each element is immutable. In Simple Associative Containers this means that the elements themselves are immutable, while in other types of Associative Containers, such as Pair Associative Containers, the elements themselves are mutable but the part of an element that is its key cannot be modified. This means that an Associative Container's value type is not Assignable.
Читать дальшеИнтервал:
Закладка:
Похожие книги на «Standard Template Library Programmer's Guide»
Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.