Ejemplo n.º 1
0
        public void SinglyLinkedListTest()
        {
            ISinglyLinkedList <int> singlylinkedlist = new SinglyLinkedList <int>();


            IPrintLinkedList printlist;

            printlist = singlylinkedlist as IPrintLinkedList;

            ISinglyLinkedNode <int> nodeone   = new SinglyLinkedNode <int>(1);
            ISinglyLinkedNode <int> nodetwo   = new SinglyLinkedNode <int>(2);
            ISinglyLinkedNode <int> nodethree = new SinglyLinkedNode <int>(3);
            ISinglyLinkedNode <int> nodefour  = new SinglyLinkedNode <int>(4);


            printlist.PrintLinkedList();

            singlylinkedlist.AddHead(nodeone);
            singlylinkedlist.AddHead(nodetwo);
            singlylinkedlist.AddHead(nodethree);
            singlylinkedlist.AddHead(nodefour);

            printlist.PrintLinkedList();

            ISinglyLinkedNode <int> temp = singlylinkedlist.GetAt(2);

            singlylinkedlist.RemoveAt(2);

            //singlylinkedlist.RemoveAfter(temp);
            //singlylinkedlist.Remove(temp);

            printlist.PrintLinkedList();

            //singlylinkedlist.RemoveHead();

            //printlist.PrintLinkedList();

            //singlylinkedlist.RemoveBefore(nodetwo);

            singlylinkedlist.ReverseList();

            printlist.PrintLinkedList();
        }