internal static int FillSortedArchetypeArray(ComponentTypeInArchetype *dst, ComponentType *requiredComponents, int count) { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (count + 1 > 1024) { throw new ArgumentException($"Archetypes can't hold more than 1024 components"); } #endif dst[0] = new ComponentTypeInArchetype(ComponentType.ReadWrite <Entity>()); for (var i = 0; i < count; ++i) { SortingUtilities.InsertSorted(dst, i + 1, requiredComponents[i]); } return(count + 1); }
private int Partition(int[] dataToBePartitioned, int lowerBound, int upperBound, int leftPivot) { if (SortingUtilities.More(dataToBePartitioned[lowerBound], dataToBePartitioned[upperBound])) { SortingUtilities.Swap(dataToBePartitioned, lowerBound, upperBound); } int l = lowerBound + 1; int h = upperBound - 1, o = lowerBound + 1, v = dataToBePartitioned[lowerBound], b = dataToBePartitioned[upperBound]; while (o <= h) { if (dataToBePartitioned[o] < v) { SortingUtilities.Swap(dataToBePartitioned, o, l); l++; } else if (dataToBePartitioned[o] >= b) { while (dataToBePartitioned[h] >= b) { h--; } SortingUtilities.Swap(dataToBePartitioned, o, h); h--; if (dataToBePartitioned[o] < v) { SortingUtilities.Swap(dataToBePartitioned, o, l); l++; } } o++; } l--; h--; SortingUtilities.Swap(dataToBePartitioned, lowerBound, l); SortingUtilities.Swap(dataToBePartitioned, upperBound, h); leftPivot = l; return(h); }
public int[] ShuffleArray(int[] input) { return(SortingUtilities.MergeSort(input, ProbabilisticComparator)); }