34 template <
typename IterType,
typename RawBinaryCompare>
37 using BinaryCompare = vtkm::cont::internal::WrappedBinaryOperator<bool, RawBinaryCompare>;
38 using ValueType =
typename std::iterator_traits<IterType>::value_type;
69 this->SerialSize = 32768;
130 const vtkm::Id numVals = range[1] - range[0];
131 assert(numVals >= 9);
136 const vtkm::Id seed = range[0] * 3 / 2 + range[1] * 11 / 3 + numVals * 10 / 7;
137 const vtkm::Id delta = (numVals / 9) * 4 / 3;
140 range[0] + ((seed + 0 * delta) % numVals), range[0] + ((seed + 1 * delta) % numVals),
141 range[0] + ((seed + 2 * delta) % numVals), range[0] + ((seed + 3 * delta) % numVals),
142 range[0] + ((seed + 4 * delta) % numVals), range[0] + ((seed + 5 * delta) % numVals),
143 range[0] + ((seed + 6 * delta) % numVals), range[0] + ((seed + 7 * delta) % numVals),
144 range[0] + ((seed + 8 * delta) % numVals)
164 swap(this->Data[origPivotIdx], this->Data[range[1] - 1]);
167 vtkm::Id2 dataCursors(range[0] - 1, range[1] - 1);
175 while (this->
Compare(this->Data[++dataCursors[0]], pivotVal))
177 while (this->
Compare(pivotVal, this->Data[--dataCursors[1]]) && dataCursors[1] > range[0])
181 if (dataCursors[0] >= dataCursors[1])
188 swap(this->Data[dataCursors[0]], this->Data[dataCursors[1]]);
192 if (!this->
Compare(this->Data[dataCursors[0]], pivotVal))
195 swap(this->Data[pivotCursors[0]], this->Data[dataCursors[0]]);
197 if (!this->
Compare(pivotVal, this->Data[dataCursors[1]]))
200 swap(this->Data[pivotCursors[1]], this->Data[dataCursors[1]]);
209 swap(this->Data[range[1] - 1], this->Data[dataCursors[0]]);
212 dataCursors =
vtkm::Id2(dataCursors[0] - 1, dataCursors[0] + 1);
214 for (
vtkm::Id i = range[0]; i < pivotCursors[0]; ++i, --dataCursors[0])
216 swap(this->Data[i], this->Data[dataCursors[0]]);
219 for (
vtkm::Id i = range[1] - 2; i > pivotCursors[1]; --i, ++dataCursors[1])
221 swap(this->Data[i], this->Data[dataCursors[1]]);
233 const vtkm::Id numVals = range[1] - range[0];
236 std::sort(this->Data + range[0], this->Data + range[1], this->Compare);
247 auto explicitThis =
this;
251 explicitThis->Sort(rhRange);