• <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://m.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 閱讀(1126) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C#

            91麻精品国产91久久久久| 97精品依人久久久大香线蕉97| 久久久久国产精品熟女影院 | 中文字幕亚洲综合久久2| 国产精品欧美亚洲韩国日本久久| 精品多毛少妇人妻AV免费久久| 日本WV一本一道久久香蕉| 欧美熟妇另类久久久久久不卡| 久久www免费人成看国产片| 久久热这里只有精品在线观看| 精品久久久久久| 亚洲色欲久久久综合网东京热| 久久精品国产一区二区三区日韩| 久久精品无码一区二区WWW| 国产福利电影一区二区三区久久久久成人精品综合 | 99久久精品国内| 日本五月天婷久久网站| 久久久亚洲精品蜜桃臀| 久久亚洲国产午夜精品理论片| 国产A级毛片久久久精品毛片| 人人狠狠综合久久亚洲婷婷| 麻豆AV一区二区三区久久| 精品国产日韩久久亚洲| 欧美激情精品久久久久久久| 国内精品久久久久久99| 久久综合给合久久狠狠狠97色69| 怡红院日本一道日本久久| 精品无码久久久久久午夜| 99久久国产宗和精品1上映| 2020久久精品亚洲热综合一本| 久久se这里只有精品| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 久久亚洲国产成人影院网站| 国产成人精品免费久久久久| 伊人久久精品无码av一区| 久久久久久久精品成人热色戒| 午夜精品久久久久久久无码| 久久男人中文字幕资源站| 久久久久国产一级毛片高清板 | 久久精品中文字幕第23页| 色成年激情久久综合|