Dervin Thunk
Dervin Thunk

Reputation: 20129

C implementation of an interval tree?

I could find a C++ one here, but no pure C one. Any pointers?

Upvotes: 4

Views: 4436

Answers (2)

fche
fche

Reputation: 2790

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.

Upvotes: 0

Prof. Falken
Prof. Falken

Reputation: 24887

C code for a red and black tree, licensed with the very generous MIT license.

(Backup at archive.org.)

Upvotes: 4

Related Questions