This still needs to be cleaned up, particularly to properly pass the texture size around--there are a few unnecessary '128x256' magic numbers scattered in the code.
18 lines
289 B
C++
18 lines
289 B
C++
#include <cstdint>
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
|
|
template <typename T>
|
|
void insertion_sort(T * arr, int len)
|
|
{
|
|
int i = 1;
|
|
while (i < len) {
|
|
int j = i;
|
|
while (j > 0 && arr[j - 1] < arr[j]) {
|
|
std::swap(arr[j - 1], arr[j]);
|
|
j -= 1;
|
|
}
|
|
i += 1;
|
|
}
|
|
}
|