Exemplo n.º 1
0
        static void Main(string[] args)
        {
            CustomDoublyLinkedList <string> linkedList = new CustomDoublyLinkedList <string>();

            //adding items
            linkedList.AddLast("two");
            linkedList.AddLast("three");
            linkedList.AddLast("four");
            linkedList.AddLast("five");

            linkedList.AddFirst("one");

            //removing items
            Console.WriteLine($"removed first: {linkedList.RemoveFirst()}");
            Console.WriteLine($"removed last: {linkedList.RemoveLast()}");

            //printing items with foreach
            linkedList.ForEach(item =>
            {
                Console.WriteLine(item);
            });

            //linkedlist items to array
            string[] arr = linkedList.ToArray();
            Console.WriteLine("LinkedListToarray:");
            Console.WriteLine(string.Join(" ", arr));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            CustomDoublyLinkedList <int> list = new CustomDoublyLinkedList <int>();

            list.AddFirst(1);
            list.AddFirst(2);
            list.AddFirst(3);

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