In article <dG76n.2639$>, Albert <> writes:
> P.S. Where's the balanced binary search tree in the STL?
If you can be sure that the C library provided to you will be the GNU
libc, you might get by with tdelete(), tfind(), tsearch(), and twalk()
from <search.h>.
http://www.opengroup.org/onlinepubs/.../search.h.html
Some characterization:
- None of these functions are standard C.
- All of them are SUS since SUSv1.
- The SUS versions don't require the trees to be balanced. (I'm saying
this after some very superficial checking.)
- The glibc implements the functions with red-black trees. See
"glibc-2.11.1/misc/tsearch.c". According to the heading comment
in that file, this is the situation since 1997. This seems to match
your balancedness requirement.
- The GNU libc provides an extension, tdestroy(); "man tdestroy".
The std::map template provides more operations. For example, you can't
easily walk two trees in lockstep with the t*() API unless you resort to
threads / longjmp() / swapcontext(), but you can easily do that with
std::map::iterator and co.
Cheers,
lacos