Пример #1
0
        public int DeleteNext()
        {
            if (next == null)
            {
                return(0);
            }
            SLinkList node = this.next;

            this.next = this.next.next;  // can be NULL here
            node      = null;
            return(1);
        }
Пример #2
0
 public void Traverse(SLinkList node)
 {
     if (node == null)
     {
         node = this;
     }
     System.Console.WriteLine("\n\nTraversing in Forward Direction\n\n");
     while (node != null)
     {
         System.Console.WriteLine(node.data);
         node = node.next;
     }
 }
Пример #3
0
        public SLinkList InsertNext(int value)
        {
            SLinkList node = new SLinkList(value);

            if (this.next == null)
            {
                // Easy to handle
                node.next = null; // already set in constructor
                this.next = node;
            }

            else
            {
                // Insert in the middle
                SLinkList temp = this.next;
                node.next = temp;
                this.next = node;
            }
            return(node);
        }
Пример #4
0
 public SLinkList(int value)
 {
     data = value;
     next = null;
 }
Пример #5
0
 public SLinkList()
 {
     data = 0;
     next = null;
 }