Sorted input warning
Inserting already sorted values is the fastest way to create the worst-case shape. If that pattern is common in your workload, this container may not be the right fit.
Because this library is a normal Binary Search Tree and not a self-balancing tree, performance depends heavily on insertion order and resulting tree height.
| Operation | Average | Worst |
|---|---|---|
| Search | O(log N) |
O(N) |
| Insert | O(log N) |
O(N) |
| Erase | O(log N) |
O(N) |
lower_bound / upper_bound |
O(log N) |
O(N) |
| Traversal | O(N) |
O(N) |
size / empty |
O(1) |
O(1) |
When the tree remains relatively balanced, lookups tend to follow short paths from the root to the requested node. When values are inserted in sorted order, the structure can become skewed and behave more like a linked list.
1
\
2
\
3
\
4
Inserting already sorted values is the fastest way to create the worst-case shape. If that pattern is common in your workload, this container may not be the right fit.
std::set better matches your requirements.