// удаление public bool Remove(T data) { CirleNode <T> current = tail.Next; // поиск удаляемого узла while (current != null) { if (current.Next.Data.Equals(data)) { break; } current = current.Next; } if ((current != null) && (current.Next != null)) { if (count == 1) { tail = null; } else { current.Next = current.Next.Next; } count--; return(true); } return(false); }
IEnumerator <T> IEnumerable <T> .GetEnumerator() { CirleNode <T> current = tail.Next; for (int i = 0; i < count; i++) { yield return(current.Data); current = current.Next; } }
public bool Contains(T data) { CirleNode <T> current = tail; while (current != null) { if (current.Data.Equals(data)) { return(true); } current = current.Next; } return(false); }
int count; // количество элементов в списке // добавление элемента public void Add(T data) { CirleNode <T> node = new CirleNode <T>(data); if (tail == null) { tail = node; tail.Next = node; } else { node.Next = tail.Next; tail.Next = node; } tail = node; count++; }
public void Clear() { tail = null; count = 0; }