public ISinglyLinkedList <T> AddLast(SinglyLinkedItem <T> newItem) { Tail.Next = newItem; Tail = Tail.Next; IncrementLength(); return(this); }
public ISinglyLinkedList <T> Clear() { Length = 0; Head = null; Tail = null; return(this); }
public ISinglyLinkedList <T> RemoveAfter(SinglyLinkedItem <T> previousItem) { if (previousItem.Next == null) { return(this); } previousItem.Next = previousItem.Next.Next; DecrementLength(); return(this); }
public ISinglyLinkedList <T> RemoveFirst() { Head = Head.Next; if (Head == null) { Tail = null; } DecrementLength(); return(this); }
public ISinglyLinkedList <T> AddFirst(SinglyLinkedItem <T> newItem) { newItem.Next = Head; Head = newItem; if (Tail == null) { Tail = newItem; } IncrementLength(); return(this); }
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); }
public ISinglyLinkedList <T> AddAfter(T data, SinglyLinkedItem <T> previousItem) { return(AddAfter(new SinglyLinkedItem <T>(data), previousItem)); }
public bool IsTail(SinglyLinkedItem <T> item) { return(Tail == item); }
public bool IsHead(SinglyLinkedItem <T> item) { return(Head == item); }