Created
July 25, 2012 07:02
-
-
Save snluu/3174846 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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