You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
template
void NthElement(T* First, T* Nth, T* Last, TFunctionRef<int(T, T)> Comparator)
{
// TODO: Use faster algorithm such as introselect.
//QuickSort(First, Last - 1, Comparator);
while (true)
{
T* Pivot = First;
T* Left = First + 1;
T* Right = Last - 1;
while (Left <= Right)
{
while (Left <= Right && Comparator(*Left, *Pivot) == 1) Left++;
while (Left <= Right && Comparator(*Right, *Pivot) == -1) Right--;
if (Left <= Right)
{
Swap(Left, Right);
Left++;
Right--;
}
}
Swap(Pivot, Right);
if (Right == Nth)
{
break;
}
else if (Nth < Right)
{
Last = Right;
}
else
{
First = Left;
}
}
}
The text was updated successfully, but these errors were encountered:
This is the NthElement function I wrote
template
void NthElement(T* First, T* Nth, T* Last, TFunctionRef<int(T, T)> Comparator)
{
// TODO: Use faster algorithm such as introselect.
//QuickSort(First, Last - 1, Comparator);
while (true)
{
T* Pivot = First;
T* Left = First + 1;
T* Right = Last - 1;
}
The text was updated successfully, but these errors were encountered: