Пример #1
0
 public void AddElements(int Value)
 {
     queue = Enqueue;
     if (queue == null)
     {
         queue         = new QueueStructure();
         queue.Data    = Value;
         queue.NextPtr = null;
         CurrentLength++;
         Enqueue = queue;
     }
     else
     {
         if (CurrentLength < queue.QueueLength)
         {
             Current = Enqueue;
             while (Current.NextPtr != null)
             {
                 Current = Current.NextPtr;
             }
             Current.NextPtr = new QueueStructure();
             Current         = Current.NextPtr;
             Current.Data    = Value;
             Current.NextPtr = null;
             CurrentLength++;
             // Console.WriteLine(CurrentLength);
         }
         else
         {
             Console.WriteLine("Queue is Full");
         }
     }
 }
Пример #2
0
 public void DisplayElements()
 {
     queue = Enqueue;
     if (queue == null)
     {
         Console.WriteLine("No Elements To Display");
     }
     while (queue != null)
     {
         Console.Write(queue.Data + " <- ");
         queue = queue.NextPtr;
     }
 }
Пример #3
0
 public void RemoveElements()
 {
     if (CurrentLength == 0)
     {
         Console.WriteLine("No Elements in Queue");
     }
     if (CurrentLength == 1)
     {
         CurrentLength = 0;
         Enqueue       = null;
     }
     else
     {
         Enqueue = Enqueue.NextPtr;
     }
     Console.WriteLine(" Element delete");
 }
Пример #4
0
        public void SortElements()
        {
            for (int queuelength = 0; queuelength < CurrentLength; queuelength++)
            {
                Current = Enqueue;
                Prev    = Enqueue;

                while (Current != null)
                {
                    if (Prev.Data > Current.Data)
                    {
                        int temp = Prev.Data;
                        Prev.Data    = Current.Data;
                        Current.Data = temp;
                    }
                    Prev    = Current;
                    Current = Current.NextPtr;
                }
            }
        }
Пример #5
0
 public QueueStructure()
 {
     Data        = 0;
     NextPtr     = null;
     QueueLength = 10;
 }