AlgoMaster Logo

std::set & std::multiset

Last Updated: May 22, 2026

High Priority
9 min read

std::set<T> is a sorted associative container that stores unique keys, and std::multiset<T> is the same container without the uniqueness rule. Both are typically backed by a balanced binary search tree (red-black tree in every major implementation), which gives O(log n) insert, lookup, and erase while keeping the elements in sorted order. This chapter covers what those guarantees provide, the full API, custom comparators, and when to prefer set over the hash-based unordered_set in the next chapter.

Premium Content

Subscribe to unlock full access to this content and more premium articles.