static void Main()
    {
        var list = new DoublyLinkedListExpanded <int>();

        list.ForEach(Console.WriteLine);
        Console.WriteLine("--------------------");

        list.AddLast(5);
        list.AddFirst(3);
        list.AddFirst(2);
        list.AddLast(10);
        Console.WriteLine("Count = {0}", list.Count);

        list.ForEach(Console.WriteLine);
        Console.WriteLine("--------------------");

        list.RemoveFirst();
        list.RemoveLast();
        list.RemoveFirst();

        list.ForEach(Console.WriteLine);
        Console.WriteLine("--------------------");

        list.RemoveLast();

        list.ForEach(Console.WriteLine);
        Console.WriteLine("--------------------");
        Console.WriteLine("2---------2--------2");
        list.AddLast(1);
        list.AddLast(2);
        list.AddLast(3);
        list.ForEach(Console.WriteLine);
        Console.WriteLine("--------------------");
        list[0] = 5;
        list[1] = 6;
        list[2] = 7;
        list.AddLast(8);
        list.AddLast(9);
        list.AddLast(10);
        list.ForEach(Console.WriteLine);
        Console.WriteLine("--------------------");
        list.InsertAt(20, 3);
        list.ForEach(Console.WriteLine);
        Console.WriteLine("3---------3--------3");
        Console.WriteLine(list.RemoveAt(4));
        Console.WriteLine("--------------------");
        list.ForEach(Console.WriteLine);
        Console.WriteLine("4---------4--------4");
        list.Clear();
        Console.WriteLine("--------------------");
        list.AddLast(8);
        list.AddLast(9);
        list.AddLast(10);
    }
示例#2
0
        public void DLLe_RemoveFirst_EmptyList_ShouldThrowException()
        {
            // Arrange
            var list = new DoublyLinkedListExpanded <int>();

            // Act
            var element = list.RemoveFirst();
        }
示例#3
0
        public void DLLe_RemoveFirst_OneElement_ShouldMakeListEmpty()
        {
            // Arrange
            var list = new DoublyLinkedListExpanded <int>();

            list.AddLast(5);

            // Act
            var element = list.RemoveFirst();

            // Assert
            Assert.AreEqual(5, element);
            Assert.AreEqual(0, list.Count);

            var items = new List <int>();

            list.ForEach(items.Add);
            CollectionAssert.AreEqual(items, new List <int>()
            {
            });
        }
示例#4
0
        public void DLLe_RemoveFirst_SeveralElements_ShouldRemoveElementsCorrectly()
        {
            // Arrange
            var list = new DoublyLinkedListExpanded <int>();

            list.AddLast(5);
            list.AddLast(6);
            list.AddLast(7);

            // Act
            var element = list.RemoveFirst();

            // Assert
            Assert.AreEqual(5, element);
            Assert.AreEqual(2, list.Count);

            var items = new List <int>();

            list.ForEach(items.Add);
            CollectionAssert.AreEqual(items, new List <int>()
            {
                6, 7
            });
        }