• <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 閱讀(1120) 評論(0)  編輯 收藏 引用 所屬分類: C#

            久久精品国产第一区二区| 潮喷大喷水系列无码久久精品| 亚洲成人精品久久| 91久久精品国产91性色也| 久久久久亚洲AV综合波多野结衣| 久久夜色精品国产亚洲| 东京热TOKYO综合久久精品| 国产激情久久久久影院小草| 亚洲精品成人网久久久久久| 久久综合九色综合网站| 久久精品国产亚洲精品| 久久人人爽人人爽人人AV东京热| 91久久香蕉国产熟女线看| 亚洲va国产va天堂va久久| 久久久久久青草大香综合精品| 97久久国产露脸精品国产| 久久免费观看视频| 9久久9久久精品| 久久精品成人欧美大片| 精品久久久久久无码人妻蜜桃 | 久久久久久久精品妇女99| 99re这里只有精品热久久| 模特私拍国产精品久久| 国产99久久久国产精免费| 久久精品99久久香蕉国产色戒 | 亚洲av成人无码久久精品 | 国产精品综合久久第一页| 久久精品国产亚洲av麻豆图片| 久久福利片| 国产精品99久久久久久www| 久久亚洲中文字幕精品有坂深雪 | 久久久久亚洲AV成人网人人网站 | 无码AV波多野结衣久久| 久久国产亚洲精品| 久久久久久亚洲精品不卡| 天天爽天天爽天天片a久久网| 99麻豆久久久国产精品免费| 久久人妻少妇嫩草AV无码专区| 无码专区久久综合久中文字幕 | 香蕉久久av一区二区三区| 精品无码久久久久国产动漫3d|