Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var duplexList = new DuplexLinkedList <int>();

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

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

            duplexList.Delete(3);

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

            var rDuplexLinkedList = duplexList.Reverse();

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

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public DuplexLinkedList <T> Reverse()
        {
            var result = new DuplexLinkedList <T>();

            var current = Tail;

            while (current != null)
            {
                result.Add(current.Data);

                current = current.Previous;
            }

            return(result);
        }