溫習下數據結構, 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)
{