Esempio n. 1
0
        public bool isSorted()
        {
            Sell <T> current = sentinel.Next;

            while (current != null)
            {
                if (current.Value.CompareTo(current.Next.Value) > 0)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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++;
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 protected void AddAfter(Sell <T> afterMe, Sell <T> newSell)
 {
     newSell.Next = afterMe.Next;
     afterMe.Next = newSell;
     count++;
 }
Esempio n. 6
0
 public SellLinkedList(T sentinelValue)
 {
     sentinel      = new Sell <T>(sentinelValue);
     sentinel.Next = null;
     count         = 0;
 }