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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
Map has the important property that inserting a new element into a map does not invalidate iterators that point to existing elements. Erasing an element from a map also does not invalidate any iterators, except, of course, for iterators that actually point to the element that is being erased.
struct ltstr {
bool operator()(const char* s1, const char* s2) const {
return strcmp(s1, s2) < 0;
}
};
int main() {
map months;
months["january"] = 31;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
months["may"] = 31;
months["june"] = 30;
months["july"] = 31;
months["august"] = 31;
months["september"] = 30;
months["october"] = 31;
months["november"] = 30;
months["december"] = 31;
cout << "june –> " << months["june"] << endl;
map::iterator cur = months.find("june");
map::iterator prev = cur;
map::iterator next = cur;
++next;
--prev;
cout << "Previous (in alphabetical order) is " << (*prev).first << endl;
cout << "Next (in alphabetical order) is " << (*next).first << endl;
}
Defined in the standard header map, and in the nonstandard backward-compatibility header map.h.
Parameter | Description | Default |
---|---|---|
Key |
The map's key type. This is also defined as map::key_type . | |
Data |
The map's data type. This is also defined as map::data_type . | |
Compare |
The key comparison function, a Strict Weak Ordering whose argument type is key_type ; it returns true if its first argument is less than its second argument, and false otherwise. This is also defined as map::key_compare . | less |
Alloc |
The map 's allocator, used for all internal memory management. | alloc |
Unique Sorted Associative Container, Pair Associative Container
• Data is Assignable.
• Compare is a Strict Weak Ordering whose argument type is Key .
• Alloc is an Allocator.
None.
Member | Where defined | Description |
---|---|---|
key_type |
Associative Container | The map 's key type, Key . |
data_type |
Pair Associative Container | The type of object associated with the keys. |
value_type |
Pair Associative Container | The type of object, pair , stored in the map. |
key_compare |
Sorted Associative Container | Function object that compares two keys for ordering. |
value_compare |
Sorted Associative Container | Function object that compares two values for ordering. |
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 map . [1] |
const_iterator |
Container | Const iterator used to iterate through a map . |
reverse_iterator |
Reversible Container | Iterator used to iterate backwards through a map . [1] |
const_reverse_iterator |
Reversible Container | Const iterator used to iterate backwards through a map . |
iterator begin() |
Container | Returns an iterator pointing to the beginning of the map . |
iterator end() |
Container | Returns an iterator pointing to the end of the map . |
const_iterator begin() const |
Container | Returns a const_iterator pointing to the beginning of the map . |
const_iterator end() const |
Container | Returns a const_iterator pointing to the end of the map . |
reverse_iterator rbegin() |
Reversible Container | Returns a reverse_iterator pointing to the beginning of the reversed map. |
reverse_iterator rend() |
Reversible Container | Returns a reverse_iterator pointing to the end of the reversed map. |
const_reverse_iterator rbegin() const |
Reversible Container | Returns a const_reverse_iterator pointing to the beginning of the reversed map. |
const_reverse_iterator rend() const |
Reversible Container | Returns a const_reverse_iterator pointing to the end of the reversed map. |
size_type size() const |
Container | Returns the size of the map . |
size_type max_size() const |
Container | Returns the largest possible size of the map . |
bool empty() const |
Container | true if the map 's size is 0 . |
key_compare key_comp() const |
Sorted Associative Container | Returns the key_compare object used by the map . |
value_compare value_comp() const |
Sorted Associative Container | Returns the value_compare object used by the map . |
map() |
Container | Creates an empty map . |
map(const key_compare& comp) |
Sorted Associative Container | Creates an empty map , using comp as the key_compare object. |
template map(InputIterator f, InputIterator l) [2] |
Unique Sorted Associative Container | Creates a map with a copy of a range. |
template map(InputIterator f, InputIterator l, const key_compare& comp) [2] |
Unique Sorted Associative Container | Creates a map with a copy of a range, using comp as the key_compare object. |
map(const map&) |
Container | The copy constructor. |
map& operator=(const map&) |
Container | The assignment operator |
void swap(map&) |
Container | Swaps the contents of two maps. |
pair insert(const value_type& x) |
Unique Associative Container | Inserts x into the map . |
iterator insert(iterator pos, const value_type& x) |
Unique Sorted Associative Container | Inserts x into the map , using pos as a hint to where it will be inserted. |
template void insert(InputIterator, InputIterator) [2] |
Unique Sorted Associative Container | Inserts a range into the map . |
void erase(iterator pos) |
Associative Container | Erases the element pointed to by pos . |
size_type erase(const key_type& k) |
Associative Container | Erases the element whose key is k . |
void erase(iterator first, iterator last) |
Associative Container | Erases all elements in a range. |
void clear() |
Associative Container | Erases all of the elements. |
iterator find(const key_type& k) |
Associative Container | Finds an element whose key is k . |
const_iterator find(const key_type& k) const |
Associative Container | Finds an element whose key is k . |
size_type count(const key_type& k) |
Unique Associative Container | Counts the number of elements whose key is k . |
iterator lower_bound(const key_type& k) |
Sorted Associative Container | Finds the first element whose key is not less than k . |
const_iterator lower_bound(const key_type& k) const |
Sorted Associative Container | Finds the first element whose key is not less than k . |
iterator upper_bound(const key_type& k) |
Sorted Associative Container | Finds the first element whose key greater than k . |
const_iterator upper_bound(const key_type& k) const |
Sorted Associative Container | Finds the first element whose key greater than k . |
pair equal_range(const key_type& k) |
Sorted Associative Container | Finds a range containing all elements whose key is k . |
pair equal_range(const key_type& k) const |
Sorted Associative Container | Finds a range containing all elements whose key is k . |
data_type& operator[](const key_type& k) [3] |
map | See below. |
bool operator==(const map&, const map&) |
Forward Container | Tests two maps for equality. This is a global function, not a member function. |
bool operator<(const map&, const map&) |
Forward Container | Lexicographical comparison. This is a global function, not a member function. |
These members are not defined in the Unique Sorted Associative Container and Pair Associative Container requirements, but are unique to map :
Читать дальшеИнтервал:
Закладка:
Похожие книги на «Standard Template Library Programmer's Guide»
Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.