Example #1
0
        public T Dequeue()
        {
            Count--;
            T data = QueueElement.Data;

            QueueElement = QueueElement.Next;
            return(data);
        }
Example #2
0
        // The IEnumerator interface requires a MoveNext method.
        public bool MoveNext()
        {
            if (_position == -1)
            {
                _position++;
                return(true);
            }

            if (currElement.Next != null)
            {
                _position++;
                currElement = currElement.Next;
                return(true);
            }

            return(false);
        }
Example #3
0
        public void Enqueue(T addElement)
        {
            Count++;
            Capacity *= Count == Capacity ? 2 : 1;
            QueueElement <T> add = new QueueElement <T>(addElement);
            QueueElement <T> beg = QueueElement;

            if (beg != null)
            {
                while (beg.Next != null)
                {
                    beg = beg.Next;
                }
                add.Next = beg.Next;
                beg.Next = add;
            }
            else
            {
                QueueElement = add;
            }
        }
Example #4
0
 public void Clear()
 {
     Count        = 0;
     QueueElement = null;
 }
Example #5
0
 //Элементы и емкости другой последовательность(not ready)
 public MyQueue(MyQueue <T> queue)
 {
     Capacity     = queue.Capacity;
     Count        = queue.Count;
     QueueElement = queue.QueueElement;
 }
Example #6
0
 public ClassEnumerator(MyQueue <T> t)
 {
     _t          = t;
     currElement = _t.QueueElement;
 }
Example #7
0
        public override bool Equals(object obj)
        {
            QueueElement <T> queue = (QueueElement <T>)obj;

            return(Data.Equals(queue.Data));
        }
Example #8
0
 public QueueElement(T d) //конструктор с параметрами
 {
     Data = d;
     Next = null;
 }
Example #9
0
        public QueueElement <T> Next; //адресное поле

        public QueueElement()         //конструктор без параметров
        {
            Data = default(T);
            Next = null;
        }