コード例 #1
0
    void TestAddBeforeAfter()
    {
        var sll = new SingleLinkedList <string>();

        print("Test Add Before/After");
        sll.AddLast("Baz");
        sll.AddBefore(sll.First, "Foo");
        sll.AddBefore(sll.GetNode(1), "Bar");
        print("Count: " + sll.Count + ", Value at 1: " + sll.GetValue(1));
        print("Expected Count: 3, Value: Bar");
        print(sll);
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: thomasbrunstrom/GMI24H
        static void ListTest()
        {
            SingleLinkedList <ImageNode> imageList = new SingleLinkedList <ImageNode>();

            imageList = new SingleLinkedList <ImageNode>();
            for (int i = 0; i < 20; i++)
            {
                var       name = "bild-" + i + ".png";
                ImageNode n    = new ImageNode();
                n.Data = name;
                imageList.AddLast(n);
            }
            Console.WriteLine(imageList);
            var addFirst  = new ImageNode("addFirst.png");
            var addAfter  = new ImageNode("AddAfter.png");
            var addBefore = new ImageNode("AddBefore.png");

            imageList.AddFirst(addFirst);
            imageList.AddAfter(addFirst, addAfter);
            imageList.AddBefore(addFirst, addBefore);
            Console.WriteLine(imageList);

            imageList.Remove(addFirst);
            Console.WriteLine(imageList);
            imageList.Remove(addAfter);
            Console.WriteLine(imageList);
            imageList.Remove(addBefore);
            Console.WriteLine(imageList);
            //
        }
コード例 #3
0
        public void AddBefore_NullNewNodeParam_ThrowsArgumentNullException()
        {
            _list.AddLast(4);
            SingleLinkedListNode <int> selectedNode = _list.Last;
            SingleLinkedListNode <int> newNode      = null;

            TestDelegate del = () => _list.AddBefore(selectedNode, newNode);

            Assert.Throws <ArgumentNullException>(del);
        }