A tree will be used as the internal data structure of std::set
. The begin
(and cbegin
) methods of std::set
have constant complexity, so std::set
must have a private data member node pointer to the first element of the set; updated by calls which modify the set.
Must std::set
also store a pointer to the root? For insert
say, one O(log(n)) operation could find the root, and another could apply the traditional algorithm afterwards. There would be overheads, but it would still have the required complexity; and each std::set
object would be one pointer smaller in size.