Example #1
0
        public override string ToString()
        {
            QueueElement <T> element = head;
            string           str     = "";

            if (count == 0)
            {
                return("Очередь пуста!");
            }
            else if (count == 1)
            {
                return(str = element.Data.ToString());
            }
            else
            {
                str     = element.Data.ToString();
                element = element.Next;
                while (element != null)
                {
                    str    += "<-" + element.Data.ToString();
                    element = element.Next;
                }
                return(str);
            }
        }
Example #2
0
        public T RemoveFromQueue()
        {
            if (count == 0)
            {
                throw new InvalidOperationException("Очередь пуста!");
            }
            T output = head.Data;

            head = head.Next;
            count--;
            return(output);
        }
Example #3
0
        public void AddToQueue(T data)
        {
            QueueElement <T> element      = new QueueElement <T>(data);
            QueueElement <T> temp_element = tail;

            tail = element;
            if (count == 0)
            {
                head = tail;
            }
            else
            {
                temp_element.Next = tail;
            }
            count++;
        }
Example #4
0
 public void Clear()
 {
     head  = null;
     tail  = null;
     count = 0;
 }