Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 public CircularLinkedList(T value)
 {
     current = value;
     next    = this;
 }