Beispiel #1
0
        static void Main(string[] args)
        {
            LinkedList LList = new LinkedList();

            LList.Insert(3);
            LList.Insert(4);
            LList.Insert(7);
            LList.Insert(9);
            LList.Insert(5);
            LList.Insert(5);
            LList.Insert(3);// loi neu them vao dau List

            LList.Delete(3);
            LList.Traverse();
            Console.ReadLine();
        }
Beispiel #2
0
        private static void Main()
        {
            LinkedList <int> list = new LinkedList <int>();

            list.Add(1);
            list.Add(5);
            list.Add(17);
            list.Add(42);
            list.AddToHead(-69);
            list.InsertAfter(1, 2);

            list.Delete(17);

            Console.WriteLine(list.Contains(8));

            foreach (int item in list)
            {
                Console.WriteLine(item);
            }

            CircularLinkedList <int> circularLinkedList = new CircularLinkedList <int>();

            circularLinkedList.Add(100);
            circularLinkedList.Add(200);
            circularLinkedList.Add(300);
            circularLinkedList.Add(400);
            circularLinkedList.InsertAfter(100, 2);
            circularLinkedList.AddToHead(0);

            circularLinkedList.Delete(200);

            Console.WriteLine(circularLinkedList.Contains(100));

            foreach (int item in circularLinkedList)
            {
                Console.WriteLine(item);
            }
        }
        static void Main(string[] args)
        {
            LinkedList ll = new LinkedList();

            NodeString toAdd = new NodeString("first");
            ll.AddNode(toAdd);
            toAdd = new NodeString("2nd");
            ll.AddNode(toAdd);
            toAdd = new NodeString("third");
            ll.AddToBack(toAdd);
            toAdd = new NodeString("4th");
            ll.AddAt(2, toAdd);
            toAdd = new NodeString("5th");
            ll.AddAt(7, toAdd);
            Console.WriteLine(ll.ToString());
            ll.Delete();
            ll.DeleteAt(8);
            ll.DeleteFromEnd();

            Console.WriteLine(ll.ToString());
            Console.WriteLine("");
            Console.WriteLine("======End of Program======");
        }