public T Dequeue() { Count--; T 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; 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; } }
public void Clear() { Count = 0; QueueElement = null; }
//Элементы и емкости другой последовательность(not ready) public MyQueue(MyQueue <T> queue) { Capacity = queue.Capacity; Count = queue.Count; QueueElement = queue.QueueElement; }
public ClassEnumerator(MyQueue <T> t) { _t = t; currElement = _t.QueueElement; }
public override bool Equals(object obj) { QueueElement <T> queue = (QueueElement <T>)obj; return(Data.Equals(queue.Data)); }
public QueueElement(T d) //конструктор с параметрами { Data = d; Next = null; }
public QueueElement <T> Next; //адресное поле public QueueElement() //конструктор без параметров { Data = default(T); Next = null; }