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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
[1] The name deque is pronounced "deck", and stands for "double-ended queue." Knuth (section 2.6) reports that the name was coined by E. J. Schweppe. See section 2.2.1 of Knuth for more information about deques. (D. E. Knuth, The Art of Computer Programming. Volume 1: Fundamental Algorithms , second edition. Addison-Wesley, 1973.)
[2] Inserting an element at the beginning or end of a deque takes amortized constant time. Inserting an element in the middle is linear in n , where n is the smaller of the number of elements from the insertion point to the beginning, and the number of elements from the insertion point to the end.
[3] The semantics of iterator invalidation for deque is as follows. Insert (including push_front and push_back ) invalidates all iterators that refer to a deque . Erase in the middle of a deque invalidates all iterators that refer to the deque . Erase at the beginning or end of a deque (including pop_front and pop_back ) invalidates an iterator only if it points to the erased element.
[4] This member function relies on member template functions, which at present (early 1998) are not supported by all compilers. If your compiler supports member templates, you can call this function with any type of input iterator. If your compiler does not yet support member templates, though, then the arguments must either be of type const value_type* or of type deque::const_iterator .
vector , list , slist
list
Category: containers
Component type: type
A list is a doubly linked list. That is, it is a Sequence that supports both forward and backward traversal, and (amortized) constant time insertion and removal of elements at the beginning or the end, or in the middle. List s have the important property that insertion and splicing do not invalidate iterators to list elements, and that even removal invalidates only the iterators that point to the elements that are removed. The ordering of iterators may be changed (that is, list::iterator might have a different predecessor or successor after a list operation than it did before), but the iterators themselves will not be invalidated or made to point to different elements unless that invalidation or mutation is explicit. [1]
Note that singly linked lists, which only support forward traversal, are also sometimes useful. If you do not need backward traversal, then slist may be more efficient than list . Definition Defined in the standard header list, and in the nonstandard backward-compatibility header list.h.
list L;
L.push_back(0);
L.push_front(1);
L.insert(++L.begin(), 2);
copy(L.begin(), L.end(), ostream_iterator(cout, " "));
// The values that are printed are 1 2 0
Parameter | Description | Default |
---|---|---|
T |
The list 's value type: the type of object that is stored in the list. | |
Alloc |
The list 's allocator, used for all internal memory management. | alloc |
Reversible Container, Front Insertion Sequence, Back Insertion Sequence.
None, except for those imposed by the requirements of Reversible Container, Front Insertion Sequence, and Back Insertion Sequence.
None.
Member | Where defined | Description |
---|---|---|
value_type |
Container | The type of object, T , stored in the list. |
pointer |
Container | Pointer to T . |
reference |
Container | Reference to T |
const_reference |
Container | Const reference to T |
size_type |
Container | An unsigned integral type. |
difference_type |
Container | A signed integral type. |
iterator |
Container | Iterator used to iterate through a list . |
const_iterator |
Container | Const iterator used to iterate through a list . |
reverse_iterator |
Reversible Container | Iterator used to iterate backwards through a list . |
const_reverse_iterator |
Reversible Container | Const iterator used to iterate backwards through a list . |
iterator begin() |
Container | Returns an iterator pointing to the beginning of the list . |
iterator end() |
Container | Returns an iterator pointing to the end of the list . |
const_iterator begin() const |
Container | Returns a const_iterator pointing to the beginning of the list . |
const_iterator end() const |
Container | Returns a const_iterator pointing to the end of the list . |
reverse_iterator rbegin() |
Reversible | Container Returns a reverse_iterator pointing to the beginning of the reversed list. |
reverse_iterator rend() |
Reversible Container | Returns a reverse_iterator pointing to the end of the reversed list. |
const_reverse_iterator rbegin() const |
Reversible Container | Returns a const_reverse_iterator pointing to the beginning of the reversed list. |
const_reverse_iterator rend() const |
Reversible Container | Returns a const_reverse_iterator pointing to the end of the reversed list. |
size_type size() const |
Container | Returns the size of the list . Note: you should not assume that this function is constant time. It is permitted to be O(N ), where N is the number of elements in the list . If you wish to test whether a list is empty, you should write L.empty() rather than L.size() == 0 . |
size_type max_size() const |
Container | Returns the largest possible size of the list . |
bool empty() const |
Container | true if the list 's size is 0 . |
list() |
Container | Creates an empty list. |
list(size_type n) |
Sequence | Creates a list with n elements, each of which is a copy of T() . |
list(size_type n, const T& t) |
Sequence | Creates a list with n copies of t . |
list(const list&) |
Container | The copy constructor. |
template list(InputIterator f, InputIterator l) [2] |
Sequence | Creates a list with a copy of a range. |
~list() |
Container | The destructor. |
list& operator=(const list&) |
Container | The assignment operator |
reference front() |
Front Insertion Sequence | Returns the first element. |
const_reference front() const |
Front Insertion Sequence | Returns the first element. |
reference back() |
Sequence | Returns the last element. |
const_reference back() const |
Back Insertion Sequence | Returns the last element. |
void push_front(const T&) |
Front Insertion Sequence | Inserts a new element at the beginning. |
void push_back(const T&) |
Back Insertion Sequence | Inserts a new element at the end. |
void pop_front() |
Front Insertion Sequence | Removes the first element. |
void pop_back() |
Back Insertion Sequence | Removes the last element. |
void swap(list&) |
Container | Swaps the contents of two lists. |
iterator insert(iterator pos, const T& x) |
Sequence | Inserts x before pos . |
template void insert(iterator pos, InputIterator f, InputIterator l) [2] |
Sequence | Inserts the range [f, l) before pos . |
void insert(iterator pos, size_type n, const T& x) |
Sequence | Inserts n copies of x before pos . |
iterator erase(iterator pos) |
Sequence | Erases the element at position pos . |
iterator erase(iterator first, iterator last) |
Sequence | Erases the range [first, last) |
void clear() |
Sequence | Erases all of the elements. |
void resize(n, t = T()) |
Sequence | Inserts or erases elements at the end such that the size becomes n . |
void splice(iterator pos, list& L) |
list |
See below. |
void splice(iterator pos, list& L, iterator i) |
list |
See below. |
void splice(iterator pos, list& L, iterator f, iterator l) |
list |
See below. |
void remove(const T& value) |
list |
See below. |
void unique() |
list |
See below. |
void merge(list& L) |
list |
See below. |
void sort() |
list |
See below. |
bool operator==(const list&, const list&) |
Forward Container | Tests two lists for equality. This is a global function, not a member function. |
bool operator<(const list&, const list&) |
Forward Container | Lexicographical comparison. This is a global function, not a member function. |
These members are not defined in the Reversible Container, Front Insertion Sequence, and Back Insertion Sequence requirements, but are specific to list .
Читать дальшеИнтервал:
Закладка:
Похожие книги на «Standard Template Library Programmer's Guide»
Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.