Beispiel #1
0
        public static void TestClear()
        {
            var list = new AlgorithmsDataStructures.LinkedList();

            list.AddInTail(new AlgorithmsDataStructures.Node(5));
            list.AddInTail(new AlgorithmsDataStructures.Node(15));
            list.AddInTail(new AlgorithmsDataStructures.Node(25));
            list.Clear();
            if (list.head == null && list.tail == null)
            {
                Console.WriteLine("TestClear PASSED");
            }
            else
            {
                Console.WriteLine("TestClear ERROR");
            }
        }
Beispiel #2
0
        public static void TestFindAll()
        {
            List <AlgorithmsDataStructures.Node> nodes1 = new List <AlgorithmsDataStructures.Node>();
            var list = new AlgorithmsDataStructures.LinkedList();

            list.AddInTail(new AlgorithmsDataStructures.Node(5));
            list.AddInTail(new AlgorithmsDataStructures.Node(5));
            list.AddInTail(new AlgorithmsDataStructures.Node(15));
            list.AddInTail(new AlgorithmsDataStructures.Node(25));
            nodes1 = list.FindAll(5);
            int i = NodeFor(nodes1, 0);

            if (i == 2)
            {
                Console.WriteLine("TestFindAll part1 PASSED");
            }
            else
            {
                Console.WriteLine("TestFindAll part1 ERROR");
            }
            nodes1.Clear();
            nodes1 = list.FindAll(51);
            i      = NodeFor(nodes1, 0);
            if (i == 0)
            {
                Console.WriteLine("TestFindAll part2 PASSED");
            }
            else
            {
                Console.WriteLine("TestFindAll part2 ERROR");
            }
            list.Clear();
            nodes1.Clear();
            nodes1 = list.FindAll(1);
            i      = NodeFor(nodes1, 0);
            if (i == 0)
            {
                Console.WriteLine("TestFindAll part3 PASSED");
            }
            else
            {
                Console.WriteLine("TestFindAll part3 ERROR");
            }
        }