c++ hash map 정렬

개발/C++

std::unordered_map 정렬하기

std::unordered_map map보다 더 빠른 탐색을 위한 자료구조 해쉬테이블로 구현한 자료구조 O(1)의 시간복잡도를 가짐 Map의 경우 O(log n)의 시간복잡도를 가짐 #include 을 선언하면 사용 가능 std::pair으로 구성되며 key가 유사한 데이터가 많으면 성능이 떨어짐 unordered_map 정렬하기 각 Value로 정렬한 후 출력을 진행하는 간단한 로직 #include #include void main() { std::unordered_map _map; _map.insert({"a",1}); _map.insert({"b",4}); _map.insert({"c",3}); _map.insert({"d",2}); //use vector for sorting std::vector..

njsung
'c++ hash map 정렬' 태그의 글 목록