public static _2List operator +(_2List l1, _2List l2) { if (l1 == null && l2 == null) { return(null); } if (l1 == null || l2 == null) { if (l1 == null) { return(l2); } else { return(l1); } } else { _2List tmp = l1; Element tmpE = l2.head; while (tmpE != null) { tmp.Add(tmpE.Value); tmpE = tmpE.Next; } return(tmp); } }
public static _2List operator +(Element e1, _2List l2) { if (e1 == null && l2 == null) { return(null); } else { if (e1 == null || l2 == null) { if (e1 == null) { return(l2); } else { return(new _2List(e1.Value)); } } else { _2List tmp = new _2List(e1.Value); Element tmpE = l2.head; while (tmpE != null) { tmp.Add(tmpE.Value); tmpE = tmpE.Next; } return(tmp); } } }
public static _2List operator +(Element e1, Element e2) { if (e1 == null && e2 == null) { return(null); } else { if (e1 == null || e2 == null) { if (e1 == null) { return(new _2List(e2.Value)); } else { return(new _2List(e1.Value)); } } else { _2List tmp = new _2List(e1.Value); tmp.Add(e2.Value); return(tmp); } } }
public static _2List operator +(_2List l1, Element e2) { if (l1 == null && e2 == null) { return(null); } else { if (l1 == null || e2 == null) { if (l1 == null) { return(new _2List(e2.Value)); } else { _2List tmp = new _2List(l1.head.Value); Element tmpE = l1.head.Next; while (tmpE != null) { tmp.Add(tmpE.Value); tmpE = tmpE.Next; } return(tmp); } } else { _2List tmp = new _2List(l1.head.Value); Element tmpE = l1.head.Next; while (tmpE != null) { tmp.Add(tmpE.Value); tmpE = tmpE.Next; } tmp.Add(e2.Value); return(tmp); } } }
/// <summary> /// Возврощает новый список, в котором с указанной позиции были удалены элементы. /// </summary> /// <param name="index"></param> /// <returns></returns> public _2List Remove(int index) { if (index > 0 && index < Count) { _2List New = new _2List(head.Value); Element tmp = new Element(); tmp = head.Next; while (index > 1) { New.Add(tmp.Value); tmp = tmp.Next; index--; } return(New); } else { return(null); } }
static _2List TestList() { _2List list = new _2List(10.123); list.Add(13.123); list.Add(100.222); list.Add(3.34); list.Add(4.453); list.Add(18.5); list.Add(6.456); list.Add(9.547); list.Add(18.78); list.Add(9.456); list.Add(100.8); list.Add(14.67); list.Add(0.223); return(list); }