public int IndexOf(T item) { int index = 0; DoubleLinkedNode <T> p = head; while (p.Next != null) { if (item.Equals(p.Next.Item))//一旦找到匹配的就立刻退出函数 { return(index); } else { index++; p = p.Next; } } return(-1); }
public virtual T this[int i] { get { if ((i < 0) || (i >= Count)) { throw new IndexOutOfRangeException("Index is out of range " + this.GetType()); } else { DoubleLinkedNode <T> p = head.Next; while (i > 0) { p = p.Next; i--; } return(p.Item); } } }
public DoubleLinkedNode() { item = default(T); front = next = null; }
public DoubleLinkedNode(T k) { item = k; front = next = null; }
public DoubleLinkedList() { head = new DoubleLinkedNode <T>(); }