//结尾追加 public void Append(T item) { BdNode <T> tnode = new BdNode <T>(item, _linkTail, null); _linkTail.Next = tnode; _linkTail = tnode; _size++; }
// 将节点插入到第index位置之前 public void Insert(T item) { BdNode <T> tnode = new BdNode <T>(item, null, _linkHead); _linkHead.Prev = tnode; _linkHead = tnode; _size++; }
public DoubleLink() { _linkHead = new BdNode <T>(default(T), null, null); //双向链表 表头为空 _linkHead.Next = _linkTail; _linkTail = new BdNode <T>(default(T), null, null); //双向链表 表头为空 _linkTail.Prev = _linkHead; _size = 0; }
public bool MoveNext() { if (_currentNode == null) { _currentNode = doubleLink._linkHead; } if (_currentNode.Next == null) { return(false); } else { _currentNode = _currentNode.Next;//进1 _current = _currentNode.Data; return(true); } //if(nextNode) //_currentNode = doubleLink._linkHead.Next; //_current = _currentNode.Data; //throw new NotImplementedException(); }
public BdNode(T val, BdNode <T> prev, BdNode <T> next) { this.Data = val; this.Prev = prev; this.Next = next; }
public void Reset() { _currentNode = null; _current = default(T); }