コード例 #1
0
        public void TestInitialize()
        {
            userNode0 = new Node(42);

            userNode1  = new Node(13);
            userNode2  = new Node(7);
            userNode3  = new Node(24);
            userNode4  = new Node(0);
            userNode5  = new Node(0);
            userNode6  = new Node(12);
            userNode7  = new Node(2);
            userNode8  = new Node(7);
            userNode9  = new Node(7);
            userNode10 = new Node(7);

            userNode11 = new Node(12);
            userNode12 = new Node(21);
            userNode13 = new Node(37);
            userNode14 = new Node(84);
            userNode15 = new Node(11);
            userNode16 = new Node(8);
            userNode17 = new Node(10);

            userList = new LinkedList2();
            userList.AddInTail(userNode1);
            userList.AddInTail(userNode2);
            userList.AddInTail(userNode3);
            userList.AddInTail(userNode4);
            userList.AddInTail(userNode5);
            userList.AddInTail(userNode6);
            userList.AddInTail(userNode7);
            userList.AddInTail(userNode8);
            userList.AddInTail(userNode9);
            userList.AddInTail(userNode10);
            Assert.AreEqual(userNode1, userList.head);
            Assert.AreEqual(userNode2, userList.head.next);
            Assert.AreEqual(null, userList.head.prev);
            Assert.AreEqual(userNode10, userList.tail);
            Assert.AreEqual(null, userList.tail.next);
            Assert.AreEqual(userNode9, userList.tail.prev);

            userListOne = new LinkedList2();
            userListOne.AddInTail(userNode0);
            Assert.AreEqual(userNode0, userListOne.head);
            Assert.AreEqual(null, userListOne.head.next);
            Assert.AreEqual(null, userListOne.head.prev);
            Assert.AreEqual(userNode0, userListOne.tail);
            Assert.AreEqual(null, userListOne.tail.next);
            Assert.AreEqual(null, userListOne.tail.prev);

            userListEmpty = new LinkedList2();
            Assert.AreEqual(null, userListEmpty.head);
            Assert.AreEqual(null, userListEmpty.tail);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Viktorzakharov/LinkedList2
        public static LinkedList2 GenerateLinkedListElements(LinkedList2 list, int count)
        {
            var n = new Random();

            while (count > 0)
            {
                list.AddInTail(new Node(n.Next(255)));
                count--;
            }
            return(list);
        }