Beispiel #1
0
 public int Count()
 {
     if (next != null)
     {
         return(1 + next.Count());
     }
     return(1);
 }
Beispiel #2
0
        public void CountMethodForDoublyLinkedNodes()
        {
            var a = new DoubleNode <char>('a');
            var b = new DoubleNode <char>('b');
            var c = new DoubleNode <char>('c');
            var d = new DoubleNode <char>('d');

            a.previous = null;
            a.next     = b;
            b.previous = a;
            b.next     = c;
            c.previous = b;
            c.next     = d;
            d.previous = c;
            d.next     = null;
            var expected = 4;
            var actual   = a.Count();

            Assert.AreEqual(expected, actual);
        }