当前位置:编程学习 > C#/ASP.NET >>

Skip List, C#实现

温习下数据结构, C#版的Skip List实现

 

\Skip List
namespace Ln.SkipList
{
    /// <summary>
    /// the values of list is ascend.
    /// </summary>
    public class SkipList
    {
        private SkipNode head;
        private System.Random randomFa = new System.Random();

        public SkipList(){}
        /// <summary>
        /// Initialize skip list
        /// </summary>
        /// <returns></returns>
        public bool Init()
        {
            head = new SkipNode(0, null, null);
            return true;
        }

        /// <summary>
        /// Clean skip list
        /// </summary>
        /// <returns></returns>
        public bool Clear()
        {
            head = null;
            return true;
        }

        /// <summary>
        /// Insert value to skip list
        /// </summary>
        /// <param name="value"></param>
        /// <returns>if the value exists in the list already, return false.</returns>
        public bool Insert(int value)
        {
          
补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,