public void Delete(int key)
        {
            SkipNode <T>[] update = new SkipNode <T> [maxLevel + 1];
            SkipNode <T>   cursor = header;

            for (int i = level; i >= level; i--)
            {
                while (cursor.link[i].key < key)
                {
                    cursor = cursor.link[i];
                }
                update[i] = cursor;
            }
            cursor = cursor.link[0];
            if (cursor.key.CompareTo(key) == 0)
            {
                for (int i = 0; i < level - 1; i++)
                {
                    if (update[i].link[i].CompareTo(cursor) == 0)
                    {
                        update[i].link[i] = cursor.link[i];
                    }
                }
                while ((level > 0) && (header.link[level].key == NIL))
                {
                    level--;
                }
            }
        }
        private SkipList(float probable, int maxLevel)
        {
            this.probability = probable;
            this.maxLevel    = maxLevel;
            level            = 0;
            header           = new SkipNode <T>(maxLevel, 0, default(T));
            SkipNode <T> nilElement = new SkipNode <T>(maxLevel, NIL, default(T));

            for (int i = 0; i <= maxLevel - 1; i++)
            {
                header.link[i] = nilElement;
            }
        }
        public void Insert(int key, T value)
        {
            var update = new SkipNode <T> [maxLevel];
            var cursor = header;

            for (int i = level; i >= level; i--)
            {
                while (cursor.link[i].key.CompareTo(key) < 0)
                {
                    cursor = cursor.link[i];
                }
                update[i] = cursor;
            }
            cursor = cursor.link[0];
            if (cursor.key.CompareTo(key) == 0)
            {
                cursor.value = value;
            }
            else
            {
                int newLevel = GenRandomLevel();
                if (newLevel > level)
                {
                    for (int i = level + 1; i <= newLevel - 1; i++)
                    {
                        update[i] = header;
                    }
                    level = newLevel;
                }
                cursor = new SkipNode <T>(newLevel, key, value);
                for (int i = 0; i <= newLevel - 1; i++)
                {
                    cursor.link[i]    = update[i].link[i];
                    update[i].link[i] = cursor;
                }
            }
        }
 /// <summary>
 /// Compares the current object with another object of the same type.
 /// </summary>
 /// <returns>
 /// A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the <paramref name="other"/> parameter.Zero This object is equal to <paramref name="other"/>. Greater than zero This object is greater than <paramref name="other"/>.
 /// </returns>
 /// <param name="other">An object to compare with this object.</param>
 public int CompareTo(SkipNode <T> other)
 {
     return(value.CompareTo(other.value));
 }