public void Execute(int index) { Dst[index] = new IndexedInt { Value = Src[index], Index = index }; }
public void Execute() { var length = IndexedSourceBuffer.Length; if (length == 0) { return; } var segmentCount = (length + (SegmentWidth - 1)) / SegmentWidth; var segmentIndex = stackalloc int[segmentCount]; var lastSharedIndex = -1; var lastSharedValue = 0; for (int sortIndex = 0; sortIndex < length; sortIndex++) { // find next best int bestSegmentIndex = -1; IndexedInt bestValue = default(IndexedInt); for (int i = 0; i < segmentCount; i++) { var startIndex = i * SegmentWidth; var offset = segmentIndex[i]; var segmentLength = ((length - startIndex) < SegmentWidth) ? (length - startIndex) : SegmentWidth; if (offset == segmentLength) { continue; } var nextValue = IndexedSourceBuffer[startIndex + offset]; if (bestSegmentIndex != -1) { if (nextValue.CompareTo(bestValue) > 0) { continue; } } bestValue = nextValue; bestSegmentIndex = i; } segmentIndex[bestSegmentIndex]++; SourceIndexBySortedSourceIndex[sortIndex] = bestValue.Index; if ((lastSharedIndex != -1) && (bestValue.Value.CompareTo(lastSharedValue) == 0)) { SharedIndexCountsBySharedIndex[lastSharedIndex]++; } else { lastSharedIndex++; lastSharedValue = bestValue.Value; SortedSourceIndexBySharedIndex.Add(sortIndex); SharedIndexCountsBySharedIndex.Add(1); } SharedIndicesBySourceIndex[bestValue.Index] = lastSharedIndex; } }