示例#1
0
        public int DeleteNext()
        {
            if (next == null)
            {
                return(0);
            }
            singleLinkedlist node = this.next;

            this.next = this.next.next;
            node      = null;
            return(1);
        }
示例#2
0
 public void Traverse(singleLinkedlist node)
 {
     if (node == null)
     {
         node = this;
     }
     System.Console.WriteLine("Traversing Singly Linked List :");
     while (node != null)
     {
         System.Console.WriteLine(node.data);
         node = node.next;
     }
 }
示例#3
0
        static void Main(string[] args)
        {
            singleLinkedlist node1 = new singleLinkedlist(100);
            singleLinkedlist node2 = node1.InsertNext(200);
            singleLinkedlist node3 = node2.InsertNext(300);
            singleLinkedlist node4 = node3.InsertNext(400);
            singleLinkedlist node5 = node4.InsertNext(500);

            node1.Traverse(null);
            Console.WriteLine("Deleting from Linked List...");
            node3.DeleteNext();
            node2.Traverse(null);
            System.Console.ReadLine();
        }
示例#4
0
        public singleLinkedlist InsertNext(int value)
        {
            singleLinkedlist node = new singleLinkedlist(value);

            if (this.next == null)
            {
                node.next = null;
                this.next = node;
            }
            else
            {
                singleLinkedlist temp = this.next;
                node.next = temp;
                this.next = node;
            }
            return(node);
        }
示例#5
0
 public singleLinkedlist(int value)
 {
     data = value;
     next = null;
 }
示例#6
0
 public singleLinkedlist()
 {
     data = 0;
     next = null;
 }