예제 #1
0
        public void AddAt()
        {
            SinglyLinkedList <int> list = new SinglyLinkedList <int>();

            list.AddEnd(0);
            list.AddEnd(1);
            list.AddEnd(2);
            list.AddAt(3, 3);
            int i = 0;

            foreach (var num in list)
            {
                Assert.True(num == i);
                i++;
            }
        }
예제 #2
0
        public void RemoveFirst()
        {
            SinglyLinkedList <int> list = new SinglyLinkedList <int>();

            list.AddEnd(2);
            list.AddEnd(3);
            list.AddEnd(1);
            list.RemoveFirst();
            int i = 3;

            foreach (var num in list)
            {
                Assert.True(num == i);
                i -= 2;
            }
        }
예제 #3
0
        public void Clear()
        {
            SinglyLinkedList <int> list = new SinglyLinkedList <int>();

            list.AddEnd(0);
            list.Clear();
            Assert.True(list.Count == 0);
        }
예제 #4
0
        public void AddAfter()
        {
            SinglyLinkedList <int> list = new SinglyLinkedList <int>();

            list.AddEnd(0);
            list.AddEnd(1);
            list.AddEnd(2);
            list.AddEnd(3);
            list.AddAfter(new SinglyLinkedNode <int>(0, new SinglyLinkedNode <int>(1)), 4);
            int i = 0;

            /*foreach (var num in list)
             * {
             *  Assert.True(num == i);
             *  i++;
             * }*/

            Assert.True(list[1] == 4);

            //Assert.True(list.Count == 5);
        }
예제 #5
0
        public void DankMemes(int[] array, int toAdd)
        {
            var test = new SinglyLinkedList <int>();

            for (int i = 0; i < array.Length; i++)
            {
                test.AddEnd(array[i]);
            }

            int length = test.Count;

            test.AddStart(toAdd);
            Assert.True(length != test.Count);
        }