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] 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 multiset::const_iterator .
Associative Container, Sorted Associative Container, Simple Associative Container, Multiple Sorted Associative Container, set , map , multimap , hash_set , hash_map , hash_multiset , hash_multimap
multimap
Category: containers
Component type: type
Multimap is a Sorted Associative Container that associates objects of type Key with objects of type Data . multimap is a Pair Associative Container, meaning that its value type is pair . It is also a Multiple Associative Container, meaning that there is no limit on the number of elements with the same key.
Multimap has the important property that inserting a new element into a multimap does not invalidate iterators that point to existing elements. Erasing an element from a multimap 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() {
multimap m;
m.insert(pair("a", 1));
m.insert(pair("c", 2));
m.insert(pair("b", 3));
m.insert(pair("b", 4));
m.insert(pair("a", 5));
m.insert(pair("b", 6));
cout << "Number of elements with key a: " << m.count("a") << endl;
cout << "Number of elements with key b: " << m.count("b") << endl;
cout << "Number of elements with key c: " << m.count("c") << endl;
cout << "Elements in m: " << endl;
for (multimap::iterator it = m.begin(); it != m.end(); ++it)
cout << " [" << (*it).first << ", " << (*it).second << "]" << endl;
}
Defined in the standard header map, and in the nonstandard backward-compatibility header multimap.h.
Parameter | Description | Default |
---|---|---|
Key |
The multimap's key type. This is also defined as multimap::key_type . | |
Data |
The multimap's data type. This is also defined as multimap::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 multimap::key_compare . | less |
Alloc |
The multimap 's allocator, used for all internal memory management. | alloc |
Multiple 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 multimap '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 multimap. |
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 multimap . [1] |
const_iterator |
Container | Const iterator used to iterate through a multimap . |
reverse_iterator |
Reversible Container | Iterator used to iterate backwards through a multimap . [1] |
const_reverse_iterator |
Reversible Container | Const iterator used to iterate backwards through a multimap . |
iterator begin() |
Container | Returns an iterator pointing to the beginning of the multimap . |
iterator end() |
Container | Returns an iterator pointing to the end of the multimap . |
const_iterator begin() const |
Container | Returns a const_iterator pointing to the beginning of the multimap . |
const_iterator end() const |
Container | Returns a const_iterator pointing to the end of the multimap . |
reverse_iterator rbegin() |
Reversible Container | Returns a reverse_iterator pointing to the beginning of the reversed multimap. |
reverse_iterator rend() |
Reversible Container | Returns a reverse_iterator pointing to the end of the reversed multimap. |
const_reverse_iterator rbegin() const |
Reversible Container | Returns a const_reverse_iterator pointing to the beginning of the reversed multimap. |
const_reverse_iterator rend() const |
Reversible Container | Returns a const_reverse_iterator pointing to the end of the reversed multimap. |
size_type size() const |
Container | Returns the size of the multimap . |
size_type max_size() const |
Container | Returns the largest possible size of the multimap . |
bool empty() const |
Container | true if the multimap 's size is 0 . |
key_compare key_comp() const |
Sorted Associative Container | Returns the key_compare object used by the multimap . |
value_compare value_comp() const |
Sorted Associative Container | Returns the value_compare object used by the multimap . |
multimap() |
Container | Creates an empty multimap . |
multimap(const key_compare& comp) |
Sorted Associative Container | Creates an empty multimap , using comp as the key_compare object. |
template multimap(InputIterator f, InputIterator l) [2] |
Multiple Sorted Associative Container | Creates a multimap with a copy of a range. |
template multimap(InputIterator f, InputIterator l, const key_compare& comp) [2] |
Multiple Sorted Associative Container | Creates a multimap with a copy of a range, using comp as the key_compare object. |
multimap(const multimap&) |
Container | The copy constructor. |
multimap& operator=(const multimap&) |
Container | The assignment operator |
void swap(multimap&) |
Container | Swaps the contents of two multimaps. |
iterator insert(const value_type& x) |
Multiple Associative Container | Inserts x into the multimap . |
iterator insert(iterator pos, const value_type& x) |
Multiple Sorted Associative Container | Inserts x into the multimap , using pos as a hint to where it will be inserted. |
template void insert(InputIterator, InputIterator) [2] |
Multiple Sorted Associative Container | Inserts a range into the multimap . |
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) |
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 . |
bool operator==(const multimap&, const multimap&) |
Forward Container | Tests two multimaps for equality. This is a global function, not a member function. |
bool operator<(const multimap&, const multimap&) |
Forward Container | Lexicographical comparison. This is a global function, not a member function. |
All of multimap 's members are defined in the Multiple Sorted Associative Container and Pair Associative Container requirements. Multimap does not introduce any new members.
Читать дальшеИнтервал:
Закладка:
Похожие книги на «Standard Template Library Programmer's Guide»
Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.