public int Recount() { int length = 0; LinkListItem <T> pointer = _first; while (pointer != null) { length++; pointer = pointer.Next; } return(length); }
public T Pop() { var listItem = _first; if (listItem == null) { return(default(T)); } _first = _first.Next; if (_first != null) { _first.Prev = null; } _length--; return(listItem.Element); }
public int Add(T element) { if (_length == 0) { _last = _first = new LinkListItem <T> { Element = element, Prev = null, Next = null }; } else { _last = _last.Next = new LinkListItem <T> { Element = element, Prev = _last, Next = null }; } return(++_length); }