Пример #1
0
        public int Deldata()
        {
            if (this.next == this)
            {
                System.Console.WriteLine("\nOnly one node...");
                return(0);
            }

            CircularLinkedList node = this.next;

            this.next = this.next.next;
            node      = null;
            return(1);
        }
Пример #2
0
        public void Traverse(CircularLinkedList node)
        {
            if (node == null)
            {
                node = this;
            }
            System.Console.WriteLine("Forward Direction...");
            CircularLinkedList snode = node;

            do
            {
                System.Console.WriteLine(node.current);
                node = node.next;
            } while (node != snode);
        }
Пример #3
0
        public CircularLinkedList Insdata(int value)
        {
            CircularLinkedList node = new CircularLinkedList(value);

            if (this.next == this)
            {
                node.next = this;
                this.next = node;
            }
            else
            {
                CircularLinkedList temp = this.next;
                node.next = temp;
                this.next = node;
            }

            return(node);
        }
Пример #4
0
        public int Gnodes(CircularLinkedList node)
        {
            if (node == null)
            {
                node = this;
            }
            int count = 0;
            CircularLinkedList snode = node;

            do
            {
                count++;
                node = node.next;
            } while (node != snode);

            System.Console.WriteLine("\nCurrent Node Value : " + node.current.ToString());
            System.Console.WriteLine("\nTotal nodes :" + count.ToString());
            return(count);
        }
Пример #5
0
 public CircularLinkedList(T value)
 {
     current = value;
     next    = this;
 }