public List() { head = new ListElement(); head.SetNum(0); head.SetNext(null); length = 0; }
public virtual void Insert(int value, ListElement pos) { ListElement temp = new ListElement(); temp.SetNum(value); temp.SetNext(pos.GetNext()); pos.SetNext(temp); ++length; }
public void Remove(ListElement pos) { ListElement temp = this.head; if (this.head.GetNext() == null) return; while (temp.GetNext() == null || temp.GetNext() != pos) { temp = temp.GetNext(); } temp.SetNext(pos.GetNext()); --length; }
public bool Find(int value) { ListElement pos = this.First(); while (pos.GetNext() != null) { if (pos.GetNext().GetNum() == value) { return(true); } pos.SetNext(pos.GetNext()); } return(false); }