C++ set, unorded_set
C++ set, unorded_set
set
1
2
3
4
5
6
7
8
9
#include<unordered_set>
std::unordered_set<std::string> s;
s.insert(”apple”);
s.insert(”ba”);
s.size();
if(s.count(”apple”)==1)
cout<< “존재함”<<”\n”;
for(const auto& e:s) // 순서없이 출력됨
cout <<e;
- 해시테이블
- 정렬안됨
- 평균 O(1)
- 빠른 검색/삽입, 순서무관 목적
This post is licensed under CC BY 4.0 by the author.