public unsafe static void RadixLSBSort(NativeArray<uint> array) { int maxDigit = (int)RadixUtil.GetMaxBinaryDigit(GetMaxValue(array)); var tempArray = new NativeArray<uint>(array.Length, Allocator.TempJob); var sortJob = new RadixLSBSortJob() { array = array, tempArray = tempArray, start = 0, end = array.Length, maxDigit = maxDigit }; sortJob.Schedule().Complete(); tempArray.Dispose(); }
public static void RadixLSBSort(List <uint> list) { uint maxDigit = RadixUtil.GetMaxBinaryDigit(GetMaxValue(list, uint.MinValue)); uint[] copyArray = new uint[list.Count]; int l, r, temp = 0; uint digit = 1; for (uint i = 0; i < maxDigit; i++) { l = 0; r = list.Count - 1; for (int j = 0; j < list.Count; j++) { if ((list[j] & digit) == 0) { copyArray[l++] = list[j]; } else { copyArray[r--] = list[j]; } } for (int j = 0; j <= r; j++) { list[j] = copyArray[j]; } temp = l; for (int j = list.Count - 1; j >= l; j--) { list[temp] = copyArray[j]; temp++; } digit <<= 1; } }