CS/C++
[Mastering C++ Programming] - unordered_map
sliver__
2022. 12. 5. 22:40
728x90
- unordered_map은 컨테이너의 내부 동작이 다르다는 점을 제외하면 맵과 유사한 방식으로 작동합니다.
- 맵은 레드-블랙 트리를 사용하고 정렬되지 않은 맵은 해시 테이블을 사용합니다.
- 맵 연산의 시간 복잡도는 O(log N)인 반면 unordered_map 연산의 시간 복잡도는 O(1)입니다.
- 따라서 unordered_map은 맵보다 빠른 경향이 있습니다.
- unordered_map에 저장된 값은 값이 키별로 정렬되는 맵과 달리 특정 방식으로 구성되지 않습니다.
- 아래의 참조를 참고한다.
https://en.cppreference.com/w/cpp/container/unordered_map
std::unordered_map - cppreference.com
(1) (since C++11) (2) (since C++17) Unordered map is an associative container that contains key-value pairs with unique keys. Search, insertion, and removal of elements have average constant-time complexity. Internally, the elements are not sorted in any p
en.cppreference.com
728x90