///<summary>Checks if list contains key</summary> ///<param name="key">Key to check</param> ///<returns>Returns true if <see cref="SkipList{T}"/> contains key otherwise return false</returns> public bool Contains(T key) { SLNode <T> current = head; for (int h = head.Level - 1; h >= 0; h--) { while (current.NextExist(h)) { int cResult = keyCompare(key, current.GetNextKey(h)); //Console.Write(key + "-" + current.GetNextKey(h) + ":"); if (cResult == 0) { return(true); } else if (cResult > 0) { current = current.Next[h]; } else { break; } } // Console.WriteLine(); } return(false); }
private SLNode <T>[] GetAddHelpData(T key) { SLNode <T>[] update = new SLNode <T> [head.Level]; SLNode <T> current = head; for (int i = head.Level - 1; i >= 0; i--) { while (current.NextExist(i)) { if (keyCompare(key, current.GetNextKey(i)) > 0) { current = current.Next[i]; } else { break; } } update[i] = current; } return(update); }