Sets and Maps

std::set stores unique values in sorted order. std::map stores key-value pairs.

#include <set>
#include <map>

set<int> s;
s.insert(10);
s.insert(5);

map<string, int> m;
m["apple"] = 2;
m["banana"] = 5;

Sets ensure uniqueness, and maps allow efficient lookup by key.

← PrevNext →