Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ MergeSortCooperatively()

void System.Linq.Parallel.SortHelper< TInputOutput, TKey >.MergeSortCooperatively ( )
inlineprivate

Definition at line 175 of file SortHelper.cs.

176 {
178 int num = _sharedBarriers.Length;
179 for (int i = 0; i < num; i++)
180 {
181 bool flag = i == num - 1;
182 int num2 = ComputePartnerIndex(i);
183 if (num2 >= _partitionCount)
184 {
185 continue;
186 }
189 TKey[] internalArray = growingArray.InternalArray;
192 if (_partitionIndex < num2)
193 {
194 int[] array3 = _sharedIndices[num2];
200 int num3 = array2.Length;
201 int num4 = array4.Length;
202 int num5 = num3 + num4;
203 int[] array5 = null;
205 if (!flag)
206 {
207 array5 = new int[num5];
208 }
213 int num6 = (num5 + 1) / 2;
214 int j = 0;
215 int num7 = 0;
216 int num8 = 0;
217 for (; j < num6; j++)
218 {
219 if ((j & 0x3F) == 0)
220 {
221 mergedCancellationToken.ThrowIfCancellationRequested();
222 }
224 {
225 if (flag)
226 {
227 array6[j] = array2[array[num7]];
228 }
229 else
230 {
231 array5[j] = array[num7];
232 }
233 num7++;
234 }
235 else
236 {
237 if (flag)
238 {
240 }
241 else
242 {
243 array5[j] = num3 + array3[num8];
244 }
245 num8++;
246 }
247 }
248 if (!flag && num3 > 0)
249 {
250 Array.Copy(array2, array6, num3);
251 }
253 continue;
254 }
259 int[] array9 = _sharedIndices[num2];
262 int num9 = array8.Length;
263 int num10 = array2.Length;
264 int num11 = num9 + num10;
265 int num12 = (num11 + 1) / 2;
266 int num13 = num11 - 1;
267 int num14 = num9 - 1;
268 int num15 = num10 - 1;
269 while (num13 >= num12)
270 {
271 if ((num13 & 0x3F) == 0)
272 {
273 mergedCancellationToken.ThrowIfCancellationRequested();
274 }
276 {
277 if (flag)
278 {
280 }
281 else
282 {
284 }
285 num14--;
286 }
287 else
288 {
289 if (flag)
290 {
292 }
293 else
294 {
296 }
297 num15--;
298 }
299 num13--;
300 }
301 if (!flag && array2.Length != 0)
302 {
303 growingArray2.CopyFrom(internalArray, array2.Length);
304 Array.Copy(array2, 0, array10, num9, array2.Length);
305 }
307 break;
308 }
309 }
readonly TInputOutput[][] _sharedValues
Definition SortHelper.cs:24
readonly int[][] _sharedIndices
Definition SortHelper.cs:20
readonly Barrier[][] _sharedBarriers
Definition SortHelper.cs:26
readonly IComparer< TKey > _keyComparer
Definition SortHelper.cs:30
readonly GrowingArray< TKey >[] _sharedKeys
Definition SortHelper.cs:22
readonly QueryTaskGroupState _groupState
Definition SortHelper.cs:18

References System.Linq.Parallel.SortHelper< TInputOutput, TKey >._groupState, System.Linq.Parallel.SortHelper< TInputOutput, TKey >._keyComparer, System.Linq.Parallel.SortHelper< TInputOutput, TKey >._partitionCount, System.Linq.Parallel.SortHelper< TInputOutput, TKey >._partitionIndex, System.Linq.Parallel.SortHelper< TInputOutput, TKey >._sharedBarriers, System.Linq.Parallel.SortHelper< TInputOutput, TKey >._sharedIndices, System.Linq.Parallel.SortHelper< TInputOutput, TKey >._sharedKeys, System.Linq.Parallel.SortHelper< TInputOutput, TKey >._sharedValues, System.array, System.Linq.Parallel.QueryTaskGroupState.CancellationState, System.Collections.Generic.IComparer< in T >.Compare(), System.Linq.Parallel.SortHelper< TInputOutput, TKey >.ComputePartnerIndex(), System.Array.Copy(), System.Linq.Parallel.GrowingArray< T >.InternalArray, System.Linq.Parallel.CancellationState.MergedCancellationToken, System.Math.Min(), and System.Threading.Barrier.SignalAndWait().

Referenced by System.Linq.Parallel.SortHelper< TInputOutput, TKey >.Sort().