public T Dequeue() { Count--; var data = QueueElement.Data; QueueElement = QueueElement.Next; return(data); }
// 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); }
public void Enqueue(T addElement) { Count++; Capacity *= Count == Capacity ? 2 : 1; var add = new QueueElement <T>(addElement); var beg = QueueElement; if (beg != null) { while (beg.Next != null) { beg = beg.Next; } add.Next = beg.Next; beg.Next = add; } else { QueueElement = add; } }
public void Clear() { Count = 0; QueueElement = null; }
public ClassEnumerator(MyQueue <T> t) { _currElement = t.QueueElement; }
public QueueElement(T d) //конструктор с параметрами { Data = d; Next = null; }
public QueueElement <T> Next; //адресное поле public QueueElement() //конструктор без параметров { Data = default(T); Next = null; }
//Элементы и емкости другой последовательность(not ready) public MyQueue(MyQueue <T> queue) { Capacity = queue.Capacity; Count = queue.Count; QueueElement = queue.QueueElement; }