I could find a C++ one here, but no pure C one. Any pointer开发者_如何学运维s?
C code for a red and black tree, licensed with the very generous MIT license.
(Backup at archive.org.)
If you limit the data to nonoverlapping segments, you can use the <search.h>
tsearch
/tfind
etc. binary-tree functions, whereby you use the integer interval tuples as keys. A supplied comparison function would easily put a total-order on segments. To find a segment that includes a given point, tfind
for a synthetic interval of width 0.
精彩评论