// Interlace the items of inList with this CustomList<T> items. public void Zip(CustomList <T> inList) { int itemsIndex = 0; int inListIndex = 0; bool thisList = true; CustomList <T> newList = new CustomList <T>(); while (itemsIndex < count || inListIndex < inList.count) { if (thisList && itemsIndex < count) // take from items { newList.Add(items[itemsIndex]); itemsIndex++; } else if (inListIndex < inList.count) // take from inList { newList.Add(inList[inListIndex]); inListIndex++; } thisList = !thisList; } CopyList(this, newList); }
// Copies CustomList<T> list2 to CustomList<T> list1. ie. list1 = list2 private void CopyList(CustomList <T> list1, CustomList <T> list2) { ClearList(list1); AppendList(list1, list2); }