Is there a TreeSet data structure equivalent in C++ with similar functions

Use std::set, which is typically implemented as a binary search tree.

Its insert(), erase() and find() methods are logarithmic in size, but can do better if a hint is given. The logarithmic complexity is reffered to the the Java TreeSet.

I think you should be interested in std::lower_bound, which returns an iterator to the lower bound, and in std::upper_bound, which returns an iterator to the upper bound.


You can use std::set
Look at std::set::lower_bound and std::set::upper_bound