示例#1
0
        public void InsertTest()
        {
            ILinearList <int> linked_list = new SiLinkedList <int>();

            linked_list.Insert(1, 0);
            linked_list.Insert(2, 0);
            linked_list.Insert(3, 2);
            linked_list.Insert(4, 10);
            Assert.AreEqual(2, linked_list.GetElem(0));
            Assert.AreEqual(1, linked_list.GetElem(1));
            Assert.AreEqual(3, linked_list.GetElem(2));
            Assert.AreEqual(4, linked_list.GetElem(3));
        }
示例#2
0
        public void DeleteTest()
        {
            ILinearList <int> linked_list = new SiLinkedList <int>();

            for (int i = 0; i < 5; i++)
            {
                linked_list.Insert(i, 0);
            }
            linked_list.Delete(0);
            linked_list.Delete(1);
            linked_list.Delete(2);
            Assert.AreEqual(2, linked_list.GetLength());
            Assert.AreEqual(3, linked_list.GetElem(0));
            Assert.AreEqual(1, linked_list.GetElem(1));
        }