Beispiel #1
0
 public override string ToString()
 {
     if (next == null)
     {
         return(value.ToString());
     }
     return(value.ToString() + " <-> " + next.ToString());
 }
Beispiel #2
0
        public override bool Equals(Object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            DoubleNode <T> p = (DoubleNode <T>)obj;

            return(p.ToString() == this.ToString());
        }
Beispiel #3
0
        public void ToStringForDoublyLinkedNodes()
        {
            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 = "a <-> b <-> c <-> d";
            var actual   = a.ToString();

            Assert.AreEqual(expected, actual);
        }