Set
Attribute
Each value in the set(no matter what type) should be unique.
Type of set
set
Elements in the set are sorted in ACSENDING order.
unordered_set
The elements in the set are NOT ordered. Save running time.
Functions
empty()
if(!set.empty()) means if the set is not empty, then go inside the if-block.
size()
set.size() will return the numbers of elements in the set.
insert()
Different from map. Map can use map[key] = value or map.insert({key, value}).
find()
Get the iterator to element. set.find(key) == set.end() means the key does not exist in the set.
count()
Count elements of the key. if set.count(key) == 0 means the key does not exist in the set.
erase(iterator position)
remove specific element
clear()
remove all the elements in the set