[ Web Proxy ]
URL:
Viewing: http://ja.cppreference.com/cpp/container/unordered_map/equal_range [Back]  [Original]

std::unordered_map<Key,T,Hash,KeyEqual,Allocator>::equal_range - cppreference.com
cppreference.com

std::unordered_map<Key,T,Hash,KeyEqual,Allocator>::equal_range

: cppreference.com
<tbody> </tbody>
std::pair<iterator,iterator> equal_range( const Key& key );
(1) (C++11)
std::pair<const_iterator,const_iterator> equal_range( const Key& key ) const;
(2) (C++11)
template< class K > std::pair<iterator,iterator> equal_range( const K& x );
(3) (C++20)
template< class K > std::pair<const_iterator,const_iterator> equal_range( const K& x ) const;
(4) (C++20)
1,2) key 2
3,4) x Hash::is_transparent KeyEqual::is_transparent Hash K Key KeyEqual Key

key -
x -

1 std::pair (end() )

key

#include <iostream>
#include <unordered_map>
 
int main()
{  
    std::unordered_map<int,char> map = {{1,'a'},{1,'b'},{1,'d'},{2,'b'}};
    auto range = map.equal_range(1);
    for (auto it = range.first; it != range.second; ++it) {
        std::cout << it->first << ' ' << it->second << '\n';
    }
}

:

1 a


() [edit]

Web Proxy Viewer  |  New URL  |  Original Page