Skip to content

Instantly share code, notes, and snippets.

@snluu
Created July 25, 2012 07:02
Show Gist options
  • Save snluu/3174846 to your computer and use it in GitHub Desktop.
Save snluu/3174846 to your computer and use it in GitHub Desktop.
void MergeList(ref List<int> list1, List<int> list2)
{
int list1Size = list1.Count;
int list2Size = list2.Count;
int totalSize = list1Size + list2Size;
list1.Capacity = totalSize;
int index1 = 0;
int index2 = 0;
while (index2 < list2Size)
{
while (list2[index2] > list1[index1])
index1++;
list1.Insert(index1, list2[index2]);
index2++;
index1++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment