/// <summary> /// Установка елемента головным /// </summary> /// <param name="data"></param> private void SetHeadItem(T data) { Head = new DuplexItem <T>(data); Head.Next = Head; Head.Previous = Head; Count = 1; }
private void SetHeadItem(T data) { var item = new DuplexItem <T>(data); Head = item; Tail = item; Count = 1; }
IEnumerator <float> IEnumerable <float> .GetEnumerator() { DuplexItem <float> current = Tail; while (current != null) { yield return(current.Data); current = current.Next; } }
public void PushFront(T data) { if (Count == 0) { SetHeadItem(data); return; } var item = new DuplexItem <T>(data); item.Previous = Head; Head.Next = item; Head = item; Count++; }
public void PushBack(T data) { if (Count == 0) { SetHeadItem(data); return; } var item = new DuplexItem <T>(data); item.Next = Tail; Tail.Previous = item; Tail = item; Count++; }
public void SetThird(float el) { DuplexItem <float> current = Head; int counter = 0; while (current != null) { if (counter == 2) { current.Data = el; } current = current.Previous; counter++; } }
public T PopFront() { if (Count > 0) { var result = Head.Data; var current = Head.Previous; current.Next = null; Head = current; Count--; return(result); } else { return(default(T)); } }
public T PopBack() { if (Count > 0) { var result = Tail.Data; var current = Tail.Next; current.Previous = null; Tail = current; Count--; return(result); } else { return(default(T)); } }
/// <summary> /// Добавление елемента в кольцевой список /// </summary> /// <param name="data"></param> public void Add(T data) { if (Count == 0) { SetHeadItem(data); return; } var item = new DuplexItem <T>(data); item.Next = Head; item.Previous = Head.Previous; Head.Previous.Next = item; Head.Previous = item; Count++; }
public float GetSixs() { float sixs = 0; DuplexItem <float> current = Head; int counter = 0; while (current != null) { if (counter == 5) { sixs = current.Data; } current = current.Previous; counter++; } return(sixs); }
/// <summary> /// Вспомогательный метод для удаления елемента /// </summary> /// <param name="current"></param> private void RemoveItem(DuplexItem <T> current) { current.Next.Previous = current.Previous; current.Previous.Next = current.Next; Count--; }
public void ClearDeq() { Tail = null; Count = 0; }