示例#1
0
        public void LongCycle()
        {
            var node0 = new LlNode <int>(0);
            var node1 = new LlNode <int>(1);

            node0.Next = node1;

            node1.Next = new LlNode <int>(2).Next = new LlNode <int>(30).Next = node1;

            Assert.That(CycleFinder.Find(node0), Is.True);
        }
示例#2
0
        public void NoCycle()
        {
            var node0 = new LlNode <int>(0);
            var node1 = new LlNode <int>(1);
            var node2 = new LlNode <int>(2);
            var node3 = new LlNode <int>(3);

            node0.Next = node1;
            node1.Next = node2;
            node2.Next = node3;

            Assert.That(CycleFinder.Find(node0), Is.False);
        }
示例#3
0
        public void LongerCycle()
        {
            var node0 = new LlNode <int>(0);
            var node1 = new LlNode <int>(1);
            var node2 = new LlNode <int>(2);
            var node3 = new LlNode <int>(3);
            var node4 = new LlNode <int>(4);
            var node5 = new LlNode <int>(5);

            node0.Next = node1;
            node1.Next = node2;
            node2.Next = node3;
            node3.Next = node4;
            node4.Next = node5;
            node5.Next = node1;

            Assert.That(CycleFinder.Find(node0), Is.True);
        }
示例#4
0
 public void Null_node()
 {
     Assert.That(CycleFinder.Find <int>(null), Is.False);
 }