public override void Insert(int index, object value) { if ((index < 0) || (index > base.Count)) { throw new ArgumentOutOfRangeException("index"); } if (base.Count == 0) { base.proot = new Node(value, null); } else if (index == 0) { base.proot = new Node(value, base.proot); } else if (index == base.Count) { this.GetNode(base.Count - 1).Next = new Node(value, null); } else { ILinkNode node = this.GetNode(index - 1); ILinkNode next = node.Next; node.Next = new Node(value, next); } base.plastIndex++; }
internal LinkEnumerator(Link link) { if (link == null) { throw new ArgumentNullException("link"); } this._link = link; this._index = -1; this._current = null; }
/// <summary> /// 输出链表里的内容 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="link"></param> public static void ShowList <T>(this ILinkNode <T> link) { LinkNode <T> node = link.node; while (node != null) { Console.WriteLine(node.data); node = node.next; } }
public static void Remove(this ILinkNode source) { if (source.GetPrev() != null) { source.GetPrev().SetNext(source.GetNext()); } if (source.GetNext() != null) { source.GetNext().SetPrev(source.GetPrev()); } source = null; }
public static void CutOff(this ILinkNode source) { if (source.GetPrev() != null) { source.GetPrev().SetNext(null); } if (source.GetNext() != null) { source.GetNext().SetPrev(null); } source = null; }
protected internal virtual ILinkNode GetNode(int index) { if ((index < 0) || (index >= this.Count)) { throw new ArgumentOutOfRangeException("index"); } ILinkNode proot = this.proot; for (int i = 0; i < index; i++) { proot = proot.Next; } return proot; }
protected internal virtual ILinkNode GetNode(int index) { if ((index < 0) || (index >= this.Count)) { throw new ArgumentOutOfRangeException("index"); } ILinkNode proot = this.proot; for (int i = 0; i < index; i++) { proot = proot.Next; } return(proot); }
public int IndexOf(object value) { ILinkNode proot = this.proot; for (int i = 0; i < this.Count; i++) { if (proot.Value == value) { return(i); } proot = proot.Next; } return(-1); }
public bool MoveNext() { if (this._index >= (this._link.Count - 1)) { return(false); } if (this._index++ == -1) { this._current = this._link.GetNode(0); } else { this._current = this._current.Next; } return(true); }
public override void RemoveAt(int index) { if ((index < 0) || (index >= base.Count)) { throw new ArgumentNullException("index"); } ILinkNode next = this.GetNode(index).Next as Node; if (index > 0) { this.GetNode(index - 1).Next = next; } else { base.proot = next; } base.plastIndex--; }
public void CopyTo(Array array, int index) { if (array == null) { throw new ArgumentNullException("array"); } if ((index < 0) || (index >= this.Count)) { throw new ArgumentOutOfRangeException("index"); } if (array.Length < (this.Count - index)) { throw new ArgumentOutOfRangeException("array is of insufficient size."); } ILinkNode next = this.GetNode(index); for (int i = index; i < this.Count; i++) { array.SetValue(next.Value, (int)(index - (index - i))); next = next.Next; } }
public Node(object value, ILinkNode next) : base(value, next) { }
protected LinkNode(object value, ILinkNode next) { this._value = value; this._next = next; }
public void Reset() { this._index = -1; this._current = null; }
public void Clear() { this.plastIndex = 0; this.proot = null; GC.Collect(); }
public static void AddPrev(this ILinkNode source, ILinkNode value) { value.SetNext(source); source.SetPrev(value); }
public bool MoveNext() { if (this._index >= (this._link.Count - 1)) { return false; } if (this._index++ == -1) { this._current = this._link.GetNode(0); } else { this._current = this._current.Next; } return true; }
public int IndexOf(object value) { ILinkNode proot = this.proot; for (int i = 0; i < this.Count; i++) { if (proot.Value == value) { return i; } proot = proot.Next; } return -1; }
public void SetPrev(ILinkNode value) { InRect.State = value == null ? 0 : 2; Prev = value; }
public void SetNext(ILinkNode value) { OutRect.State = value == null ? 0 : 2; Next = value; }
public Node(object value, ILinkNode previous, ILinkNode next) : base(value, next) { this._previous = previous; }
public static void AddNext(this ILinkNode source, ILinkNode value) { source.SetNext(value); value.SetPrev(source); }