private void BuildIntLinkedListRandom(SCLinkedList <int> list, int start, int end) { for (int i = start; i <= end; ++i) { list.InsertTail(i); } WriteLine("Build:[{0}:{1}]", start, end); }
public void Push(T data) { if (m_List == null) { m_List = new SCLinkedList <T>(); } m_List.InsertHead(data); }
private void BuildStringLinkedListRandom(SCLinkedList <string> list, int start, int end) { for (int i = start; i <= end; ++i) { list.InsertTail(string.Format("Index:{0}", i)); } WriteLine("Build:[{0}:{1}]", start, end); }
private void TestInt() { WriteBegin("LinkListTest(Int)"); SCLinkedList <int> list = new SCLinkedList <int>(); BuildIntLinkedListRandom(list, 0, 10); BuildIntLinkedListRandom(list, 11, 20); RemoveListAtIndex(list, 19); RemoveListAtIndex(list, 0); RemoveData(list, 7); VisitList(list); FindData(list, 9); WriteEnd("LinkListTest(Int)"); }
private void TestString() { WriteBegin("LinkListTest(String)"); SCLinkedList <string> list = new SCLinkedList <string>(); BuildStringLinkedListRandom(list, 0, 10); BuildStringLinkedListRandom(list, 11, 20); RemoveListAtIndex(list, 19); RemoveListAtIndex(list, 0); RemoveData(list, "Index:7"); VisitList(list); FindData(list, "Index:9"); WriteEnd("LinkListTest(String)"); }
protected void FindData <T>(SCLinkedList <T> list, T data) { WriteLine("FindData{0}: Result:{1}", data, list.Query(data)); }
private void VisitList <T>(SCLinkedList <T> list) { WriteLine("Data Begin:"); list.Accept(VisitData); WriteLine(""); }
private void RemoveData <T>(SCLinkedList <T> list, T data) { WriteLine("Remove Data:{0}-Result:{1}", data, list.Remove(data)); }
private void RemoveListAtIndex <T>(SCLinkedList <T> list, int index) { WriteLine("Remove At:{0}-Result:{1}", index, list.RemoveAt(index)); }