I would like to know how a set is implemented in C++. If I were to implement my own set container without using the STL provided container, what would be the best way to go
cppreference says:
Sets are usually implemented as red-black trees.
I checked, and both libc++
and libstdc++
do use red-black trees for std::set
.
std::unordered_set
was implemented with a hash table in libc++
and I presume the same for libstdc++
but didn't check.
Edit: Apparently my word is not good enough.
libc++
: 1 2libstdc++
: 1