public void RemoveAt(int index) { if (index == 0) { core = core.Next; } else { if (index >= this.Count) { throw new IndexOutOfRangeException(); } ListComponent <T> pointer = core; for (int i = 0; i < index - 1; i++) { if (pointer is NullElement <T> ) { throw new IndexOutOfRangeException(); } pointer = pointer.Next; } ListComponent <T> afterCompontent = pointer.Next.Next; pointer.PushNext(afterCompontent); } }
public override void PushEnd(ListComponent <T> component) { ListComponent <T> pointer = this; while (!(pointer.Next is NullElement <T>)) { pointer = pointer.Next; } pointer.PushNext(component); }
public void Insert(int index, T item) { ListComponent <T> pointer = core; for (int i = 0; i < index; i++) { if (pointer is NullElement <T> ) { throw new IndexOutOfRangeException(); } pointer = pointer.Next; } ListComponent <T> afterCompontent = pointer.Next; ListComponent <T> intermediateComp = new ListComposite <T>() { Value = item }; intermediateComp.PushNext(afterCompontent); pointer.PushNext(intermediateComp); }