示例#1
0
        private void InsertLast()
        {
            Console.Write("Enter The Data You Want To Store : ");
            string ii;

            do
            {
                ii = Console.ReadLine();
            } while (ii == "");
            if (info == "")
            {
                info = ii;
            }
            else
            {
                NormalNode newNode = new NormalNode
                {
                    info = ii
                };
                NormalNode current = this;
                while (current.next != null)
                {
                    current = current.next;
                }
                current.next = newNode;
            }
        }
示例#2
0
 private void DeleteData()
 {
     if (info == "")
     {
         Console.WriteLine("No Data Present To Delete..\n Deletition couldn't be performed");
         Console.ReadKey();
     }
     else
     {
         NormalNode current = this;
         NormalNode parent  = null;
         Console.Write("\nWhich Data You want to Delete : ");
         String cmp = Console.ReadLine();
         while ((current != null) && (current.info.ToLower().Equals(cmp.ToLower()) == false))
         {
             parent  = current;
             current = current.next;
         }
         if (current == null)
         {
             Console.WriteLine($"{cmp} Not Present..\n Deletition couldn't be performed");
             Console.ReadKey();
         }
         else if (parent == null)
         {
             this.DeleteFirst();
         }
         else
         {
             parent.next = current.next;
             //current = null;
         }
     }
 }
示例#3
0
 private void DeleteLast()
 {
     if (info == "")
     {
         Console.WriteLine("No Data Present To Delete..\n Deletition couldn't be performed");
         Console.ReadKey();
     }
     else
     {
         NormalNode current = this;
         NormalNode parent  = null;
         while (current.next != null)
         {
             parent  = current;
             current = current.next;
         }
         if (parent == null)
         {
             this.DeleteFirst();
         }
         else
         {
             parent.next = null;
             //current = null;
         }
     }
 }
示例#4
0
        private void DisplayAll()
        {
            NormalNode current = this;

            Console.Write("Nodes :");
            if (info == "")
            {
                Console.WriteLine("   Empty Linear Node\n");
            }
            else
            {
                do
                {
                    Console.Write($"  {current.info}    ");
                    current = current.next;
                } while (current != null);
                Console.WriteLine("\n");
            }
        }
示例#5
0
        private void InsertAfter()
        {
            Console.Write("Enter The Data You Want To Store : ");
            string ii;

            do
            {
                ii = Console.ReadLine();
            } while (ii == "");
            if (info == "")
            {
                Console.WriteLine("No Data present in the List..\n DATA NOT INSERTED");
                Console.ReadKey();
            }
            else
            {
                NormalNode newNode = new NormalNode
                {
                    info = ii
                };
                NormalNode current = this;
                Console.Write("\nAfter which Data You want to Store : ");
                String cmp = Console.ReadLine();
                while ((current != null) && (current.info.ToLower().Equals(cmp.ToLower()) == false))
                {
                    current = current.next;
                }
                if (current == null)
                {
                    Console.WriteLine($"{cmp} not found in Nodes..\n DATA NOT INSERTED");
                    Console.ReadKey();
                }
                else
                {
                    newNode.next = current.next;
                    current.next = newNode;
                }
            }
        }
示例#6
0
 private void DeleteFirst()
 {
     if (info == "")
     {
         Console.WriteLine("No Data Present To Delete..");
         Console.ReadKey();
     }
     else
     {
         NormalNode current = this.next;
         if (current == null)
         {
             this.info = "";
         }
         else
         {
             this.info = current.info;
             this.next = current.next;
             //current = null;
         }
     }
 }
示例#7
0
        private void InsertFront()
        {
            Console.Write("Enter The Data You Want To Store : ");
            string ii;

            do
            {
                ii = Console.ReadLine();
            } while (ii == "");
            if (info == "")
            {
                info = ii;
            }
            else
            {
                NormalNode newNode = new NormalNode();
                newNode.info = this.info;
                newNode.next = this.next;
                this.info    = ii;
                this.next    = newNode;
            }
        }
示例#8
0
 public NormalNode()
 {
     info = "";
     next = null;
 }