Ejemplo n.º 1
0
        static void LinkedListMain()
        {
            var list = new DataStructures.LinkedList.LinkedList <int>();

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

            list.AddTail(12);

            var head     = list.Head;
            var nextItem = head.Next;
            var oldNext  = nextItem.Next;

            nextItem.Next = new ListNode <int>(555, oldNext);

            Print(list);

            Console.WriteLine(list[1]);
            list[4] = 44;
            Print(list);
            list.Remove(5);
            Print(list);
            list.Add(5);
            list.Remove(6);
            Print(list);
        }
Ejemplo n.º 2
0
        public void TestAdd_ShouldAddElements()
        {
            //arrange
            //var linkedList = new DataStructures.LinkedList.LinkedList<int>(); //create SUT
            //act
            _linkedList.Add(1);
            _linkedList.Add(2);
            _linkedList.Add(3);
            //assert
            var result = _linkedList.ToArray();

            result.Should().BeEquivalentTo(new[] { 3, 2, 1, 568, 666, 0 });
        }