Finding C++ interval tree algorithm implementation [duplicate]

霸气de小男生 提交于 2019-11-27 21:36:19

I've written a template-based interval tree implementation in C++, https://github.com/ekg/intervaltree. MIT license. Enjoy.

The C++ standard library offers red/black trees std::map, std::multimap, std::set and std::multiset.

Really, I can't think of any way to handle this more efficiently than to keep a std::map of iterator pairs, and passing those iterator pairs to upper_bound() and lower_bound(). You'd want the iterator pairs to be kept in a map themselves so that you could easily zero in on which pairs are likely to be in the interval (if the beginning iterator in the "candidate interval" comes after the end of the given interval you're looking at, then you can skip checking that -- and all later -- iterator pairs).

cos

There's also a C# implementation of Interval tree at this link. It's easy enough to translate to C++ for those in need

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!