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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
Reversible Container, reverse_bidirectional_iterator, Random Access Iterator, iterator tags, Iterator Overview
reverse_bidirectional_iterator
Categories: iterators, adaptors
Component type: type
Reverse_bidirectional_iterator is an iterator adaptor that enables backwards traversal of a range. Operator++ applied to an object of class reverse_bidirectional_iterator means the same thing as operator-- applied to an object of class BidirectionalIterator . There are two different reverse iterator adaptors: the class reverse_bidirectional_iterator has a template argument that is a Bidirectional Iterator, and the class reverse_iterator has a template argument that is a Random Access Iterator. [1]
template
void forw(const list & L) {
list::iterator first = L.begin();
list::iterator last = L.end();
while (first != last) cout << *first++ << endl;
}
template
void rev(const list & L) {
typedef reverse_bidirectional_iterator::iterator, T, list::reference_type, list::difference_type> reverse_iterator; [2]
reverse_iterator rfirst(L.end());
reverse_iterator rlast(L.begin());
while (rfirst != rlast) cout << *rfirst++ << endl;
}
In the function forw , the elements are printed in the order *first , *(first+1) , …, *(last-1) . In the function rev , they are printed in the order *(last – 1) , *(last - 2) , …, *first . [3]
Defined in the standard header iterator, and in the nonstandard backward-compatibility header iterator.h. This class is no longer part of the C++ standard, but it was present in early drafts, and it is retained in this implementation for backward compatibility.
Parameter | Description | Default |
---|---|---|
BidirectionalIterator |
The base iterator class. Incrementing an object of class reverse_bidirectional_iterator corresponds to decrementing an object of class BidirectionalIterator . | |
T |
The reverse iterator's value type. This should always be the same as the base iterator's value type. | |
Reference |
The reverse iterator's reference type. This should always be the same as the base iterator's reference type. | T& |
Distance |
The reverse iterator's distance type. This should always be the same as the base iterator's distance type. | ptrdiff_t |
Bidirectional Iterator.
The base iterator type (that is, the template parameter BidirectionalIterator ) must be a Bidirectional Iterator . The reverse_bidirectional_iterator 's value type, reference type, and distance type (that is, the template parameters T , Reference , and Distance , respectively) must be the same as the base iterator's value type, reference type, and distance type.
None.
Member | Where defined | Description |
---|---|---|
self |
reverse_bidirectional_iterator |
See below |
reverse_bidirectional_iterator() |
Trivial Iterator | The default constructor |
reverse_bidirectional_iterator(const reverse_bidirectional_iterator& x) |
Trivial Iterator | The copy constructor |
reverse_bidirectional_iterator& operator=(const reverse_bidirectional_iterator& x) |
Trivial Iterator | The assignment operator |
reverse_bidirectional_iterator(BidirectionalIterator x) |
reverse_bidirectional_iterator |
See below. |
BidirectionalIterator base() |
reverse_bidirectional_iterator | See below. |
Reference operator*() const |
Trivial Iterator | The dereference operator |
reverse_bidirectional_iterator& operator++() |
Forward Iterator | Preincrement |
reverse_bidirectional_iterator operator++(int) |
Forward Iterator | Postincrement |
reverse_bidirectional_iterator& operator--() |
Bidirectional Iterator | Predecrement |
reverse_bidirectional_iterator operator--(int) |
Bidirectional Iterator | Postdecrement |
bool operator==(const reverse_bidirectional_iterator&, const reverse_bidirectional_iterator&) |
Trivial Iterator | Compares two iterators for equality. This is a global function, not a member function. |
bidirectional_iterator_tag iterator_category(const reverse_bidirectional_iterator&) |
Iterator tags | Returns the iterator's category. This is a global function, not a member function. |
T* value_type(const reverse_bidirectional_iterator&) |
Iterator tags | Returns the iterator's value type. This is a global function, not a member function. |
Distance* distance_type(const reverse_bidirectional_iterator&) |
Iterator tags | Returns the iterator's distance type. This is a global function, not a member function. |
These members are not defined in the Bidirectional Iterator requirements, but are specific to reverse_bidirectional_iterator .
Member | Description |
---|---|
self |
A typedef for reverse_bidirectional_iterator . |
BidirectionalIterator base() |
Returns the current value of the reverse_bidirectional_iterator 's base iterator. If ri is a reverse iterator and i is any iterator, the two fundamental identities of reverse iterators can be written as reverse_bidirectional_iterator(i).base() == i and &*ri == &*(ri.base() – 1) . |
reverse_bidirectional_iterator(BidirectionalIterator i) |
Constructs a reverse_bidirectional_iterator whose base iterator is i . |
[1] There isn't really any good reason to have two separate classes: this separation is purely because of a technical limitation in some of today's C++ compilers. If the two classes were combined into one, then there would be no way to declare the return types of the iterator tag functions iterator_category , distance_type and value_type correctly. The iterator traits class solves this problem: it addresses the same issues as the iterator tag functions, but in a cleaner and more flexible manner. Iterator traits, however, rely on partial specialization , and many C++ compilers do not yet implement partial specialization. Once compilers that support partial specialization become more common, these two different reverse iterator classes will be combined into a single class.
Читать дальшеИнтервал:
Закладка:
Похожие книги на «Standard Template Library Programmer's Guide»
Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.