Macaulay2 Engine
Loading...
Searching...
No Matches

◆ sort_partition()

int MatrixSorter::sort_partition ( int lo,
int hi )
inlineprivate

Definition at line 78 of file matrix-sort.cpp.

79 {
80 int pivot = sort_vals[lo];
81 int i = lo - 1;
82 int j = hi + 1;
83 for (;;)
84 {
85 do
86 {
87 j--;
88 }
89 while (sort_compare(sort_vals[j], pivot) < 0);
90 do
91 {
92 i++;
93 }
94 while (sort_compare(sort_vals[i], pivot) > 0);
95
96 if (i < j)
97 {
98 int tmp = sort_vals[j];
99 sort_vals[j] = sort_vals[i];
100 sort_vals[i] = tmp;
101 }
102 else
103 return j;
104 }
105 }
int sort_compare(int i, int j)

References sort_compare(), and sort_vals.

Referenced by sort_range().