Пример #1
0
 public ISinglyLinkedList <T> AddLast(SinglyLinkedItem <T> newItem)
 {
     Tail.Next = newItem;
     Tail      = Tail.Next;
     IncrementLength();
     return(this);
 }
Пример #2
0
 public ISinglyLinkedList <T> Clear()
 {
     Length = 0;
     Head   = null;
     Tail   = null;
     return(this);
 }
Пример #3
0
        public ISinglyLinkedList <T> RemoveAfter(SinglyLinkedItem <T> previousItem)
        {
            if (previousItem.Next == null)
            {
                return(this);
            }

            previousItem.Next = previousItem.Next.Next;
            DecrementLength();
            return(this);
        }
Пример #4
0
        public ISinglyLinkedList <T> RemoveFirst()
        {
            Head = Head.Next;

            if (Head == null)
            {
                Tail = null;
            }
            DecrementLength();
            return(this);
        }
Пример #5
0
        public ISinglyLinkedList <T> AddFirst(SinglyLinkedItem <T> newItem)
        {
            newItem.Next = Head;
            Head         = newItem;

            if (Tail == null)
            {
                Tail = newItem;
            }

            IncrementLength();
            return(this);
        }
Пример #6
0
        public ISinglyLinkedList <T> AddAfter(SinglyLinkedItem <T> newItem, SinglyLinkedItem <T> previousItem)
        {
            if (previousItem == null)
            {
                return(this);
            }

            previousItem.Next = newItem;
            IncrementLength();

            if (IsTail(previousItem))
            {
                Tail = newItem;
            }

            return(this);
        }
Пример #7
0
 public ISinglyLinkedList <T> AddAfter(T data, SinglyLinkedItem <T> previousItem)
 {
     return(AddAfter(new SinglyLinkedItem <T>(data), previousItem));
 }
Пример #8
0
 public bool IsTail(SinglyLinkedItem <T> item)
 {
     return(Tail == item);
 }
Пример #9
0
 public bool IsHead(SinglyLinkedItem <T> item)
 {
     return(Head == item);
 }