public IEnumerator GetEnumerator() { LinkListNode temp = first; while (temp != null) { yield return(temp.Value); temp = temp.next; } }
public IEnumerator <T> GetEnumerator() { LinkListNode <T> current = first; while (current != null) { yield return(current.Value); current = current.next; } }
public LinkListNode last; //链表的最后一个节点指针 public LinkListNode AddLast(object node) //添加一个节点 { var newNode = new LinkListNode(node); if (first == null) { first = newNode; last = first; } else { last.next = newNode; newNode.prev = last; last = newNode; } return(newNode); }
public LinkListNode <T> AddLast(T node) { LinkListNode <T> newNode = new LinkListNode <T>(node); if (first == null) //此链表无内容 { first = newNode; last = first; } else { last.next = newNode; newNode.prev = last; last = newNode; } return(newNode); }