• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            brent's hut

            Red Black Tree in C#

            Several weeks ago, I tried hard to search an implement of balance binary tree in C#,  what i needed was something like std::set<key, comparator> in C++: the data should be sorted, can be inserted and deleted at low cost and provides iterator which can move forward and backward. It looks like this can be easily achieved by List<T> with List<T>.Sort and List<T>.BinarySearch, the problem is that the performance of List<T> is not acceptable when the data collection size is big in my case.

            I failed to find anything that can be used directly, it is hard to believe, a lot of implement of red-black tree in Java or C++ can be easily got from internet (although none of them meets my requirement), but none in C#.

            So I had to implement one, it was translated from a C++ implement and modified to provide an immutable node.

            Source code 
            http://www.shnenglu.com/Files/aqazero/RBTree.zip
            Use at your own risk!
            Example:
             1         RBTree<int> rbt = new RBTree<int>(Comparer<int>.Default);
             2         rbt.Add(3);
             3         rbt.Add(1);
             4         rbt.Add(10);
             5         rbt.Add(6);
             6         rbt.Add(7);
             7         rbt.Remove(10);
             8         RBNode<int> node6 = rbt.GetNode(6);
             9         rbt.Remove(node6);
            10 
            11         RBNode<int> node = rbt.GetNode(3);
            12         node = node.Prev;
            13         while (null != node)
            14         {
            15             System.Diagnostics.Trace.WriteLine(node.Value);
            16             node = node.Next;
            17         }

            Output:
            1
            3
            7

            posted on 2017-04-29 05:02 brent 閱讀(1120) 評論(0)  編輯 收藏 引用 所屬分類: C#

            久久只有这精品99| 中文字幕无码免费久久| av国内精品久久久久影院| 久久久久久久人妻无码中文字幕爆| 久久无码专区国产精品发布| 欧美伊人久久大香线蕉综合| 亚洲精品乱码久久久久66| 久久精品国产亚洲精品2020| 一级做a爰片久久毛片16| 久久亚洲欧洲国产综合| 国产亚洲精品久久久久秋霞 | 久久久久久久波多野结衣高潮| 久久婷婷色综合一区二区| 99国产精品久久久久久久成人热| 国产精品久久久99| 人妻丰满AV无码久久不卡| 91精品国产91久久久久久| 2020久久精品亚洲热综合一本| 欧美牲交A欧牲交aⅴ久久| 久久精品国产一区二区三区不卡 | 亚洲欧洲久久av| 97久久精品国产精品青草| 亚洲国产成人久久综合一区77 | 最新久久免费视频| 26uuu久久五月天| 亚洲精品美女久久777777| 久久无码一区二区三区少妇| 久久99中文字幕久久| 午夜精品久久久久久久久| 久久亚洲电影| 久久久WWW成人免费精品| 91精品国产91久久| 久久精品草草草| 久久精品国产亚洲av麻豆色欲| 久久婷婷色香五月综合激情| 久久se精品一区二区影院| 99久久99这里只有免费的精品| 国内精品伊人久久久久av一坑| 久久香蕉国产线看观看精品yw| 久久亚洲美女精品国产精品| 国产精品99久久久精品无码|