C# Interval tree class

2019-01-24 22:16发布

I'm looking for an interval tree C# collection class.

I need to be able to add intervals, idealy 2D, otherwise perhaps I could combine two standard 1D interval trees.

I also need to be able to find out what intervals overlap a given interval.

I found this intervaltree.codeplex.com but

There are no downloads associated with this release.

edit:

Continue here: C# using others code

5条回答
狗以群分
2楼-- · 2019-01-24 22:57

I just wrote another implementation which can be found here: https://github.com/mbuchetics/RangeTree

It also comes with an asynchronous version which rebuilds the tree using the Task Parallel Library (TPL).

查看更多
Explosion°爆炸
3楼-- · 2019-01-24 23:06

For future visitors, I've written an implementation as well https://github.com/vvondra/Interval-Tree

查看更多
你好瞎i
4楼-- · 2019-01-24 23:06

you can find another c# implementation for an interval tree (based on a self balancing avl tree) @ http://code.google.com/p/intervaltree/

查看更多
仙女界的扛把子
5楼-- · 2019-01-24 23:09

Yet another implementation can be found at https://github.com/erdomke/RangeTree. Unlike other implementations, it aims to have an interface that is similar to IDictionary<TKey, TValue> where possible. It can be used as follows:

var tree = new RangeTree<int, string>()
{
    { 0, 10, "1" },
    { 20, 30, "2" },
    { 15, 17, "3" },
    { 25, 35, "4" },
};

// Alternatively, use the Add method, for example:
// tree.Add(0, 10, "1");

var results1 = tree[5]; // 1 item: [0 - 10] "1"
查看更多
看我几分像从前
6楼-- · 2019-01-24 23:16

There is a download on the codeplex page: http://intervaltree.codeplex.com/SourceControl/list/changesets -> Right hand side -> Download

查看更多
登录 后发表回答