Skip to content

Commit adc5adf

Browse files
Tyler WhitneyTyler Whitney
authored andcommitted
initial draft
1 parent 18ac0b0 commit adc5adf

File tree

8 files changed

+414
-67
lines changed

8 files changed

+414
-67
lines changed

docs/standard-library/map-class.md

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: "map Class"
3-
ms.date: "10/18/2018"
4-
f1_keywords: ["map/std::map", "map/std::map::allocator_type", "map/std::map::const_iterator", "map/std::map::const_pointer", "map/std::map::const_reference", "map/std::map::const_reverse_iterator", "map/std::map::difference_type", "map/std::map::iterator", "map/std::map::key_compare", "map/std::map::key_type", "map/std::map::mapped_type", "map/std::map::pointer", "map/std::map::reference", "map/std::map::reverse_iterator", "map/std::map::size_type", "map/std::map::value_type", "map/std::map::at", "map/std::map::begin", "map/std::map::cbegin", "map/std::map::cend", "map/std::map::clear", "map/std::map::count", "map/std::map::crbegin", "map/std::map::crend", "map/std::map::emplace", "map/std::map::emplace_hint", "map/std::map::empty", "map/std::map::end", "map/std::map::equal_range", "map/std::map::erase", "map/std::map::find", "map/std::map::get_allocator", "map/std::map::insert", "map/std::map::key_comp", "map/std::map::lower_bound", "map/std::map::max_size", "map/std::map::rbegin", "map/std::map::rend", "map/std::map::size", "map/std::map::swap", "map/std::map::upper_bound", "map/std::map::value_comp"]
5-
helpviewer_keywords: ["std::map [C++]", "std::map [C++], allocator_type", "std::map [C++], const_iterator", "std::map [C++], const_pointer", "std::map [C++], const_reference", "std::map [C++], const_reverse_iterator", "std::map [C++], difference_type", "std::map [C++], iterator", "std::map [C++], key_compare", "std::map [C++], key_type", "std::map [C++], mapped_type", "std::map [C++], pointer", "std::map [C++], reference", "std::map [C++], reverse_iterator", "std::map [C++], size_type", "std::map [C++], value_type", "std::map [C++], at", "std::map [C++], begin", "std::map [C++], cbegin", "std::map [C++], cend", "std::map [C++], clear", "std::map [C++], count", "std::map [C++], crbegin", "std::map [C++], crend", "std::map [C++], emplace", "std::map [C++], emplace_hint", "std::map [C++], empty", "std::map [C++], end", "std::map [C++], equal_range", "std::map [C++], erase", "std::map [C++], find", "std::map [C++], get_allocator", "std::map [C++], insert", "std::map [C++], key_comp", "std::map [C++], lower_bound", "std::map [C++], max_size", "std::map [C++], rbegin", "std::map [C++], rend", "std::map [C++], size", "std::map [C++], swap", "std::map [C++], upper_bound", "std::map [C++], value_comp"]
3+
ms.date: "9/9/2020"
4+
f1_keywords: ["map/std::map", "map/std::map::allocator_type", "map/std::map::const_iterator", "map/std::map::const_pointer", "map/std::map::const_reference", "map/std::map::const_reverse_iterator", "map/std::map::difference_type", "map/std::map::iterator", "map/std::map::key_compare", "map/std::map::key_type", "map/std::map::mapped_type", "map/std::map::pointer", "map/std::map::reference", "map/std::map::reverse_iterator", "map/std::map::size_type", "map/std::map::value_type", "map/std::map::at", "map/std::map::begin", "map/std::map::cbegin", "map/std::map::cend", "map/std::map::clear", "map/std::map::count", "map/std::map::contains", "map/std::map::crbegin", "map/std::map::crend", "map/std::map::emplace", "map/std::map::emplace_hint", "map/std::map::empty", "map/std::map::end", "map/std::map::equal_range", "map/std::map::erase", "map/std::map::find", "map/std::map::get_allocator", "map/std::map::insert", "map/std::map::key_comp", "map/std::map::lower_bound", "map/std::map::max_size", "map/std::map::rbegin", "map/std::map::rend", "map/std::map::size", "map/std::map::swap", "map/std::map::upper_bound", "map/std::map::value_comp"]
5+
helpviewer_keywords: ["std::map [C++]", "std::map [C++], allocator_type", "std::map [C++], const_iterator", "std::map [C++], const_pointer", "std::map [C++], const_reference", "std::map [C++], const_reverse_iterator", "std::map [C++], difference_type", "std::map [C++], iterator", "std::map [C++], key_compare", "std::map [C++], key_type", "std::map [C++], mapped_type", "std::map [C++], pointer", "std::map [C++], reference", "std::map [C++], reverse_iterator", "std::map [C++], size_type", "std::map [C++], value_type", "std::map [C++], at", "std::map [C++], begin", "std::map [C++], cbegin", "std::map [C++], cend", "std::map [C++], clear", "std::map [C++], count", "std::map [C++], contains", "std::map [C++], crbegin", "std::map [C++], crend", "std::map [C++], emplace", "std::map [C++], emplace_hint", "std::map [C++], empty", "std::map [C++], end", "std::map [C++], equal_range", "std::map [C++], erase", "std::map [C++], find", "std::map [C++], get_allocator", "std::map [C++], insert", "std::map [C++], key_comp", "std::map [C++], lower_bound", "std::map [C++], max_size", "std::map [C++], rbegin", "std::map [C++], rend", "std::map [C++], size", "std::map [C++], swap", "std::map [C++], upper_bound", "std::map [C++], value_comp"]
66
ms.assetid: 7876f4c9-ebb4-4878-af1e-09364c43af0a
77
---
88
# map Class
@@ -98,32 +98,33 @@ The map orders the elements it controls by calling a stored function object of t
9898
9999
|Member function|Description|
100100
|-|-|
101-
|[at](#at)|Finds an element with a specified key value.|
102-
|[begin](#begin)|Returns an iterator that points to the first element in the map.|
103-
|[cbegin](#cbegin)|Returns a const iterator that points to the first element in the map.|
101+
|[at](#at)|Finds an element with the specified key value.|
102+
|[begin](#begin)|Returns an iterator that points to the first element in the `map`.|
103+
|[cbegin](#cbegin)|Returns a const iterator that points to the first element in the `map`.|
104104
|[cend](#cend)|Returns a const past-the-end iterator.|
105-
|[clear](#clear)|Erases all the elements of a map.|
105+
|[clear](#clear)|Erases all the elements of a `map`.|
106+
|[contains](#contains)|Checks if there is an element with the specified key in the `map`.|
106107
|[count](#count)|Returns the number of elements in a map whose key matches the key specified in a parameter.|
107-
|[crbegin](#crbegin)|Returns a const iterator that points to the first element in a reversed map.|
108-
|[crend](#crend)|Returns a const iterator that points to the location after the last element in a reversed map.|
109-
|[emplace](#emplace)|Inserts an element constructed in place into the map.|
110-
|[emplace_hint](#emplace_hint)|Inserts an element constructed in place into the map, with a placement hint.|
111-
|[empty](#empty)|Returns **`true`** if a map is empty.|
108+
|[crbegin](#crbegin)|Returns a const iterator that points to the first element in a reversed `map`.|
109+
|[crend](#crend)|Returns a const iterator that points to the location after the last element in a reversed `map`.|
110+
|[emplace](#emplace)|Inserts an element constructed in place into the `map`.|
111+
|[emplace_hint](#emplace_hint)|Inserts an element constructed in place into the `map`, with a placement hint.|
112+
|[empty](#empty)|Returns **`true`** if a `map` is empty.|
112113
|[end](#end)|Returns the past-the-end iterator.|
113114
|[equal_range](#equal_range)|Returns a pair of iterators. The first iterator in the pair points to the first element in a `map` with a key that is greater than a specified key. The second iterator in the pair points to the first element in the `map` with a key that is equal to or greater than the key.|
114115
|[erase](#erase)|Removes an element or a range of elements in a map from the specified positions.|
115-
|[find](#find)|Returns an iterator that points to the location of an element in a map that has a key equal to a specified key.|
116-
|[get_allocator](#get_allocator)|Returns a copy of the `allocator` object that is used to construct the map.|
117-
|[insert](#insert)|Inserts an element or a range of elements into the map at a specified position.|
118-
|[key_comp](#key_comp)|Returns a copy of the comparison object that used to order keys in a map.|
119-
|[lower_bound](#lower_bound)|Returns an iterator to the first element in a map that has a key value that is equal to or greater than that of a specified key.|
120-
|[max_size](#max_size)|Returns the maximum length of the map.|
121-
|[rbegin](#rbegin)|Returns an iterator that points to the first element in a reversed map.|
122-
|[rend](#rend)|Returns an iterator that points to the location after the last element in a reversed map.|
116+
|[find](#find)|Returns an iterator that points to the location of an element in a `map` that has a key equal to a specified key.|
117+
|[get_allocator](#get_allocator)|Returns a copy of the `allocator` object that is used to construct the `map`.|
118+
|[insert](#insert)|Inserts an element or a range of elements into the `map` at a specified position.|
119+
|[key_comp](#key_comp)|Returns a copy of the comparison object that used to order keys in a `map`.|
120+
|[lower_bound](#lower_bound)|Returns an iterator to the first element in a `map` that has a key value that is equal to or greater than that of a specified key.|
121+
|[max_size](#max_size)|Returns the maximum length of the `map`.|
122+
|[rbegin](#rbegin)|Returns an iterator that points to the first element in a reversed m`ap.|
123+
|[rend](#rend)|Returns an iterator that points to the location after the last element in a reversed `map`.|
123124
|[size](#size)|Returns the number of elements in the map.|
124125
|[swap](#swap)|Exchanges the elements of two maps.|
125-
|[upper_bound](#upper_bound)|Returns an iterator to the first element in a map that has a key value that is greater than that of a specified key.|
126-
|[value_comp](#value_comp)|Retrieves a copy of the comparison object that is used to order element values in a map.|
126+
|[upper_bound](#upper_bound)|Returns an iterator to the first element in a `map` that has a key value that is greater than that of a specified key.|
127+
|[value_comp](#value_comp)|Retrieves a copy of the comparison object that is used to order element values in a `map`.|
127128
128129
### Operators
129130
@@ -526,6 +527,47 @@ The number of elements in m1 with a sort key of 2 is: 1.
526527
The number of elements in m1 with a sort key of 3 is: 0.
527528
```
528529

530+
## <a name="contains"></a> contains
531+
532+
Checks if there is an element the specified key in the `map` .
533+
534+
```cpp
535+
[[nodiscard]] bool contains(const K& key) const;
536+
```
537+
538+
### Parameters
539+
540+
*key*\
541+
The element's key value to look for.
542+
543+
### Return Value
544+
545+
`true` if the element is found in the container; `false` otherwise.
546+
547+
### Remarks
548+
549+
`Contains()` is new in C++20. To use it, specify the [std:c++latest](../build/reference/std-specify-language-standard-version.md) compiler option.
550+
551+
### Example
552+
553+
```cpp
554+
// Requires /std:c++latest
555+
#include <map>
556+
#include <iostream>
557+
558+
int main()
559+
{
560+
std::map<int, bool> theMap = {{0, true},{1, false}};
561+
std::cout << std::boolalpha << theMap.contains(1) << '\n';
562+
std::cout << std::boolalpha << theMap.contains(2) << '\n';
563+
}
564+
```
565+
566+
```Output
567+
true
568+
false
569+
```
570+
529571
## <a name="crbegin"></a> crbegin
530572

531573
Returns a const iterator addressing the first element in a reversed map.

docs/standard-library/multimap-class.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: "multimap Class"
3-
ms.date: "10/18/2018"
4-
f1_keywords: ["map/std::multimap", "map/std::multimap::allocator_type", "map/std::multimap::const_iterator", "map/std::multimap::const_pointer", "map/std::multimap::const_reference", "map/std::multimap::const_reverse_iterator", "map/std::multimap::difference_type", "map/std::multimap::iterator", "map/std::multimap::key_compare", "map/std::multimap::key_type", "map/std::multimap::mapped_type", "map/std::multimap::pointer", "map/std::multimap::reference", "map/std::multimap::reverse_iterator", "map/std::multimap::size_type", "map/std::multimap::value_type", "map/std::multimap::begin", "map/std::multimap::cbegin", "map/std::multimap::cend", "map/std::multimap::clear", "map/std::multimap::count", "map/std::multimap::crbegin", "map/std::multimap::crend", "map/std::multimap::emplace", "map/std::multimap::emplace_hint", "map/std::multimap::empty", "map/std::multimap::end", "map/std::multimap::equal_range", "map/std::multimap::erase", "map/std::multimap::find", "map/std::multimap::get_allocator", "map/std::multimap::insert", "map/std::multimap::key_comp", "map/std::multimap::lower_bound", "map/std::multimap::max_size", "map/std::multimap::rbegin", "map/std::multimap::rend", "map/std::multimap::size", "map/std::multimap::swap", "map/std::multimap::upper_bound", "map/std::multimap::value_comp"]
5-
helpviewer_keywords: ["std::multimap [C++]", "std::multimap [C++], allocator_type", "std::multimap [C++], const_iterator", "std::multimap [C++], const_pointer", "std::multimap [C++], const_reference", "std::multimap [C++], const_reverse_iterator", "std::multimap [C++], difference_type", "std::multimap [C++], iterator", "std::multimap [C++], key_compare", "std::multimap [C++], key_type", "std::multimap [C++], mapped_type", "std::multimap [C++], pointer", "std::multimap [C++], reference", "std::multimap [C++], reverse_iterator", "std::multimap [C++], size_type", "std::multimap [C++], value_type", "std::multimap [C++], begin", "std::multimap [C++], cbegin", "std::multimap [C++], cend", "std::multimap [C++], clear", "std::multimap [C++], count", "std::multimap [C++], crbegin", "std::multimap [C++], crend", "std::multimap [C++], emplace", "std::multimap [C++], emplace_hint", "std::multimap [C++], empty", "std::multimap [C++], end", "std::multimap [C++], equal_range", "std::multimap [C++], erase", "std::multimap [C++], find", "std::multimap [C++], get_allocator", "std::multimap [C++], insert", "std::multimap [C++], key_comp", "std::multimap [C++], lower_bound", "std::multimap [C++], max_size", "std::multimap [C++], rbegin", "std::multimap [C++], rend", "std::multimap [C++], size", "std::multimap [C++], swap", "std::multimap [C++], upper_bound", "std::multimap [C++], value_comp"]
3+
ms.date: "9/9/2020"
4+
f1_keywords: ["map/std::multimap", "map/std::multimap::allocator_type", "map/std::multimap::const_iterator", "map/std::multimap::const_pointer", "map/std::multimap::const_reference", "map/std::multimap::const_reverse_iterator", "map/std::multimap::difference_type", "map/std::multimap::iterator", "map/std::multimap::key_compare", "map/std::multimap::key_type", "map/std::multimap::mapped_type", "map/std::multimap::pointer", "map/std::multimap::reference", "map/std::multimap::reverse_iterator", "map/std::multimap::size_type", "map/std::multimap::value_type", "map/std::multimap::begin", "map/std::multimap::cbegin", "map/std::multimap::cend", "map/std::multimap::clear", "map/std::multimap::contains", "map/std::multimap::count", "map/std::multimap::crbegin", "map/std::multimap::crend", "map/std::multimap::emplace", "map/std::multimap::emplace_hint", "map/std::multimap::empty", "map/std::multimap::end", "map/std::multimap::equal_range", "map/std::multimap::erase", "map/std::multimap::find", "map/std::multimap::get_allocator", "map/std::multimap::insert", "map/std::multimap::key_comp", "map/std::multimap::lower_bound", "map/std::multimap::max_size", "map/std::multimap::rbegin", "map/std::multimap::rend", "map/std::multimap::size", "map/std::multimap::swap", "map/std::multimap::upper_bound", "map/std::multimap::value_comp"]
5+
helpviewer_keywords: ["std::multimap [C++]", "std::multimap [C++], allocator_type", "std::multimap [C++], const_iterator", "std::multimap [C++], const_pointer", "std::multimap [C++], const_reference", "std::multimap [C++], const_reverse_iterator", "std::multimap [C++], difference_type", "std::multimap [C++], iterator", "std::multimap [C++], key_compare", "std::multimap [C++], key_type", "std::multimap [C++], mapped_type", "std::multimap [C++], pointer", "std::multimap [C++], reference", "std::multimap [C++], reverse_iterator", "std::multimap [C++], size_type", "std::multimap [C++], value_type", "std::multimap [C++], begin", "std::multimap [C++], cbegin", "std::multimap [C++], cend", "std::multimap [C++], clear", "std::multimap [C++], contains", "std::multimap [C++], count", "std::multimap [C++], crbegin", "std::multimap [C++], crend", "std::multimap [C++], emplace", "std::multimap [C++], emplace_hint", "std::multimap [C++], empty", "std::multimap [C++], end", "std::multimap [C++], equal_range", "std::multimap [C++], erase", "std::multimap [C++], find", "std::multimap [C++], get_allocator", "std::multimap [C++], insert", "std::multimap [C++], key_comp", "std::multimap [C++], lower_bound", "std::multimap [C++], max_size", "std::multimap [C++], rbegin", "std::multimap [C++], rend", "std::multimap [C++], size", "std::multimap [C++], swap", "std::multimap [C++], upper_bound", "std::multimap [C++], value_comp"]
66
ms.assetid: 8796ae05-37c4-475a-9e61-75fde9d4a463
77
---
88
# multimap Class
@@ -97,6 +97,7 @@ In C++14 you can enable heterogeneous lookup by specifying the `std::less<>` or
9797
|[cbegin](#cbegin)|Returns a const iterator addressing the first element in the `multimap`.|
9898
|[cend](#cend)|Returns a const iterator that addresses the location succeeding the last element in a `multimap`.|
9999
|[clear](#clear)|Erases all the elements of a `multimap`.|
100+
|[contains](#contains)|Checks if there is an element with the specified key in the `multimap`.|
100101
|[count](#count)|Returns the number of elements in a `multimap` whose key matches a parameter-specified key.|
101102
|[crbegin](#crbegin)|Returns a const iterator addressing the first element in a reversed `multimap`.|
102103
|[crend](#crend)|Returns a const iterator that addresses the location succeeding the last element in a reversed `multimap`.|
@@ -406,6 +407,48 @@ To access the value of the key for the element, use `crIter->first`, which is eq
406407

407408
See the example for [rend](#rend) for an example of how to declare and use `const_reverse_iterator`.
408409

410+
## <a name="contains"></a> contains
411+
412+
Checks if there is an element the specified key in the `multimap` .
413+
414+
```cpp
415+
[[nodiscard]] bool contains(const K& key) const;
416+
```
417+
418+
### Parameters
419+
420+
*key*\
421+
The element's key value to look for.
422+
423+
### Return Value
424+
425+
`true` if the element is found in the container; `false` otherwise.
426+
427+
### Remarks
428+
429+
`Contains()` is new in C++20. To use it, specify the [std:c++latest](../build/reference/std-specify-language-standard-version.md) compiler option.
430+
431+
### Example
432+
433+
```cpp
434+
// Requires /std:c++latest
435+
#include <map>
436+
#include <iostream>
437+
438+
int main()
439+
{
440+
std::multimap<int, bool> theMultiMap = {{0, false}, {1, true}};
441+
442+
std::cout << std::boolalpha << theMultiMap.contains(1) << '\n';
443+
std::cout << std::boolalpha << theMultiMap.contains(2) << '\n';
444+
}
445+
```
446+
447+
```Output
448+
true
449+
false
450+
```
451+
409452
## <a name="count"></a> multimap::count
410453

411454
Returns the number of elements in a multimap whose keys match a parameter-specified key.

0 commit comments

Comments
 (0)