Esempio n. 1
0
        static void Main(string[] args)
        {
            Model.LinkedList <int> l1 = new Model.LinkedList <int>(1);
            l1.Add(2);
            l1.Add(3);
            l1.Add(4);
            l1.Add(5);
            foreach (var item in l1)
            {
                Console.Write(item + " ");
            }

            Console.WriteLine(System.Environment.NewLine);

            l1.Del(3);
            foreach (var item in l1)
            {
                Console.Write(item + " ");
            }

            Console.WriteLine(System.Environment.NewLine);


            l1.AddToHead(10);
            l1.AddAfterItem(4, 11);

            foreach (var item in l1)
            {
                Console.Write(item + " ");
            }

            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var list = new Model.LinkedList <int>();

            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);
            list.Add(5);

            foreach (var item in list)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            list.Delete(4);
            list.Delete(2);
            list.Delete(13);

            foreach (var item in list)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            list.AppendHead(7);

            foreach (var item in list)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            list.InsertAfter(3, 8);

            foreach (var item in list)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            Console.ReadLine();
        }