コード例 #1
0
        public void TestMix2()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            list.RemoveFirstItem();
            list.RemoveLastItem();

            list.AddFirstItem(new Node(4));
            list.AddLastItem(new Node(5));

            AssertValues(list, 4, 2, 5);
        }
コード例 #2
0
        public void TestAdd1()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            Node node1 = new Node(1);

            list.AddLastItem(node1);

            Node node2 = new Node(2);

            list.AddLastItem(node2);

            Assert.AreEqual(list.size, 2);

            Assert.AreEqual(list.listFirst, node1);
            Assert.AreEqual(list.listLast, node2);

            Assert.IsNull(list.listFirst.listPrev);
            Assert.AreEqual(list.listFirst.listNext, node2);

            Assert.AreEqual(list.listLast.listPrev, node1);
            Assert.IsNull(list.listLast.listNext);
        }
コード例 #3
0
        public void TestRemove4()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            Node node = Find(list, 3);

            list.RemoveItem(node);

            AssertValues(list, 1, 2);
        }
コード例 #4
0
        public void TestInsert13()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            Node node = new Node(4);

            list.InsertAfterItem(list.listLast, node);

            AssertValues(list, 1, 2, 3, 4);
        }
コード例 #5
0
        public void TestMix4()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            while (list.size > 0)
            {
                list.RemoveLastItem();
            }

            AssertValues(list);
        }
コード例 #6
0
        public void TestRemove9()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            Node node = Find(list, 2);

            list.RemoveItem(node);

            Assert.IsNull(node.listPrev);
            Assert.IsNull(node.listNext);
        }
コード例 #7
0
        public void TestInsert10()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            Node insertNode = Find(list, 3);

            Node node = new Node(4);

            list.InsertBeforeItem(insertNode, node);

            AssertValues(list, 1, 2, 4, 3);
        }
コード例 #8
0
        public void TestAdd3()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            Assert.AreEqual(list.size, 3);

            Node node = list.listFirst;

            for (int i = 0; i < values.Length; ++i)
            {
                Assert.AreEqual(values[i], node.value);
                node = node.listNext;
            }

            Assert.IsNull(node);
        }