Skip to content

Commit

Permalink
Merge pull request Bhupesh-V#507 from Subham-Mallick/equal_range
Browse files Browse the repository at this point in the history
Added equal_range in Map dir
  • Loading branch information
Bhupesh-V authored Oct 20, 2020
2 parents b50dc9b + 12a61cf commit 0839850
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion map/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
:heavy_check_mark: [size](size.md)
:heavy_check_mark: [swap](swap.md)
:heavy_check_mark: [upper_bound](upper_bound.md)
:x: equal_range
:heavy_check_mark: [equal_range](equal_range.md)
:x: extract
:x: insert_or_assign
:x: key_comp
Expand Down
32 changes: 32 additions & 0 deletions map/equal_range.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# equal_range
**Description :** Returns the bounds of a range that includes all the elements in the container which have a key equivalent to k.

**Example** :

```cpp
// Demonstrates equal_range

#include <iostream>
#include <map>

int main (){
std::map<char,int> mymap;

mymap['a']=10;
mymap['b']=20;
mymap['c']=30;

std::pair<std::map<char,int>::iterator,std::map<char,int>::iterator> ret;
ret = mymap.equal_range('b');

std::cout << "lower bound points to: ";
std::cout << ret.first->first << " => " << ret.first->second << '\n';

std::cout << "upper bound points to: ";
std::cout << ret.second->first << " => " << ret.second->second << '\n';

return 0;
}

```
**[Run Code](https://rextester.com/PDL21133)**

0 comments on commit 0839850

Please sign in to comment.