C# Interval tree class

前端 未结 5 1636
名媛妹妹
名媛妹妹 2020-12-17 05:51

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 tree

5条回答
  •  自闭症患者
    2020-12-17 06:35

    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 where possible. It can be used as follows:

    var tree = new RangeTree()
    {
        { 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"
    

提交回复
热议问题