Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
import extensions;
|
||||
|
||||
extension op
|
||||
{
|
||||
insertionSort()
|
||||
= self.clone().insertionSort(0, self.Length - 1);
|
||||
|
||||
insertionSort(int first, int last)
|
||||
{
|
||||
for(int i := first + 1, i <= last, i += 1)
|
||||
{
|
||||
var entry := self[i];
|
||||
int j := i;
|
||||
|
||||
while (j > first && self[j - 1] > entry)
|
||||
{
|
||||
self[j] := self[j - 1];
|
||||
|
||||
j -= 1
|
||||
};
|
||||
|
||||
self[j] := entry
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public program()
|
||||
{
|
||||
var list := new int[]{3, 9, 4, 6, 8, 1, 7, 2, 5};
|
||||
|
||||
console.printLine("before:", list.asEnumerable());
|
||||
console.printLine("after :", list.insertionSort().asEnumerable());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue