static void TestLinkedList() { //AnLinkedListNode<int> one = new AnLinkedListNode<int>(1); //AnLinkedListNode<int> two = new AnLinkedListNode<int>(4); //AnLinkedListNode<int> three = new AnLinkedListNode<int>(7); //AnLinkedListNode<int> four = new AnLinkedListNode<int>(3); MyLinkedList <int> list = new MyLinkedList <int>(); list.Add(1); list.Add(4); list.Add(7); list.Add(3); IEnumerator <int> en = list.GetEnumerator(); while (en.MoveNext()) { Console.WriteLine(en.Current); } list.AddFirst(0); Console.WriteLine("---"); IEnumerator <int> en2 = list.GetEnumerator(); while (en2.MoveNext()) { Console.WriteLine(en2.Current); } Console.WriteLine("---"); Console.WriteLine("remove 4 ? {0}", list.Remove(4)); Console.WriteLine("---"); en2 = list.GetEnumerator(); while (en2.MoveNext()) { Console.WriteLine(en2.Current); } Console.WriteLine("---"); Console.WriteLine("remove 3 ? {0}", list.Remove(3)); Console.WriteLine("---"); en2 = list.GetEnumerator(); while (en2.MoveNext()) { Console.WriteLine(en2.Current); } Console.WriteLine("---"); Console.WriteLine("remove first ? {0}", list.RemoveFirst()); en2 = list.GetEnumerator(); while (en2.MoveNext()) { Console.WriteLine(en2.Current); } Console.WriteLine("---"); }
public static void Main() { MyLinkedList mll = new MyLinkedList(10); mll.AddFirst(11); mll.AddFirst(12); mll.AddFirst(13); mll.Add(4, 8); mll.Add(4, 9); mll.PrintList(); }
static void ListTest() { MyLinkedList <int> list = new MyLinkedList <int>(); int N = 20; for (int i = 0; i < N; i++) { Console.WriteLine("Try to Add num: " + i); list.Add(i); } int num = 6; Console.WriteLine("\nTry to Search num: " + num); int val = list.Search(num); Console.WriteLine("Finded number: " + val); num = 8; Console.WriteLine("\nTry to delete number: " + num); list.Delete(num); try { Console.WriteLine("Try to Search num: " + num); val = list.Search(num); } catch (Exception e) { Console.WriteLine("Number " + num + " not found"); } Console.Read(); }
static void Main(string[] args) { var linkedList = new MyLinkedList <int>(); linkedList.Add(5); linkedList.Add(7); linkedList.Add(8); linkedList.Add(7); linkedList.Print(); //linkedList.Delete(10); // linkedList.Delete(8); //linkedList.Insert(6,3); // linkedList.Reverse(); // linkedList.Update(3,1); linkedList.Access(1); linkedList.Print(); Console.ReadLine(); }