/// <summary> /// Creating of a list /// </summary> public List() { head = new ListElement(); head.data = 0; head.next = null; length = 0; }
/// <summary> /// ADding value to the list /// </summary> /// <param name="value">value</param> /// <param name="pos">position</param> public void AddToList(int value, ListElement pos) { ListElement tmp = new ListElement(); tmp.data = value; tmp.next = pos.next; pos.next = tmp; length++; }
/// <summary> /// Deleting from list /// </summary> /// <param name="pos">position</param> public void DeleteFromList(ListElement pos) { ListElement tmp = this.head; if (this.head.next == null) return; while (tmp.next == null || tmp.next != pos) { tmp = tmp.next; } tmp.next = pos.next; length--; }
public ListElement Next(ListElement pos) { return pos.next; }
/// <summary> /// Returns /// </summary> /// <param name="pos"></param> /// <returns></returns> public int Retrieve(ListElement pos) { return pos.data; }