public LRUCache(int capacity) { dLinkList = new DLinkList <T>(); findDic = new Dictionary <uint, DLinkNode <T> >(); nodePool = GetOrCreateClassPool(capacity); }
static void Main(string[] args) { ILinearList<string> lst = new DLinkList<string>(); lst.Insert(0, "a1"); lst.Insert(1, "a2"); lst.Insert(2, "a3"); lst.Remove(1); Console.WriteLine(lst.Length); for (int i = 0; i < lst.Length; i++) { Console.WriteLine(lst[i]); } }
static void Main(string[] args) { //单链表 LinkList <string> link = new LinkList <string>(); link.Append("123"); link.Append("abc"); link.Append("jgh"); link.Insert("sde", 2); int length = link.getLength(); int k = link.Locate("567"); string m = link.GetElem(3); Console.WriteLine("567的位置为" + k); Console.WriteLine("位置为3的值为" + m); Console.WriteLine("链表的长度为" + length); Node <string> n = link.Head; while (n != null) { Console.WriteLine(n.Data); n = n.Next; } Console.WriteLine("-----------"); DLinkList <string> DL = new DLinkList <string>(); DL.Append("abc"); DL.Append("cde"); DL.Insert("efg", 2); DNode <string> p = DL.DLinkHead; while (p != null) { Console.WriteLine(p.Data); p = p.Next; } Console.Read(); }
public LRUCache(int capacity) { list = new DLinkList(); dic = new Dictionary <int, Node>(); _capacity = capacity; }