public bool isSorted() { Sell <T> current = sentinel.Next; while (current != null) { if (current.Value.CompareTo(current.Next.Value) > 0) { return(false); } } return(true); }
public Sell <T> FindSellBefore(T value) { Sell <T> current = sentinel; while (current.Next != null) { if (current.Next.Value.Equals(value)) { return(current); } current = current.Next; } return(null); }
public void AddAtEnd(T value) { //работает, если нет цикла Sell <T> newSell = new Sell <T>(value); Sell <T> current = sentinel; while (current.Next != null) { current = current.Next; } current.Next = newSell; newSell.Next = null; count++; }
public T getMax() { Sell <T> current = sentinel.Next; if (current == null) { throw new Exception("Попытка найти максимальный элемент впустом списке."); } T max = current.Value; while (current.Next != null) { if (max.CompareTo(current.Next.Value) < 0) { max = current.Next.Value; } current = current.Next; } return(max); }
protected void AddAfter(Sell <T> afterMe, Sell <T> newSell) { newSell.Next = afterMe.Next; afterMe.Next = newSell; count++; }
public SellLinkedList(T sentinelValue) { sentinel = new Sell <T>(sentinelValue); sentinel.Next = null; count = 0; }