7#include "numeric_array.h"
14 template < prototype_array ARRAY >
15 void swap_quick_sort(ARRAY & a, const ::function<
void(index, index) > & swap)
18 index_array stackLowerBound;
19 index_array stackUpperBound;
20 ::collection::index iLowerBound;
21 ::collection::index iUpperBound;
22 ::collection::index iLPos, iUPos, iMPos;
24 if (this->get_size() >= 2)
26 stackLowerBound.push(0);
27 stackUpperBound.push(this->get_size() - 1);
30 iLowerBound = stackLowerBound.pop();
31 iUpperBound = stackUpperBound.pop();
41 if (!(a.element_at(iUPos) < a.element_at(iMPos)))
58 if (!(a.element_at(iMPos) < a.element_at(iLPos)))
71 if (iLowerBound < iMPos - 1)
73 stackLowerBound.push(iLowerBound);
74 stackUpperBound.push(iMPos - 1);
76 if (iMPos + 1 < iUpperBound)
78 stackLowerBound.push(iMPos + 1);
79 stackUpperBound.push(iUpperBound);
81 if (stackLowerBound.get_size() == 0)
89 template<
typename SWAP>
90 void case_insensitive_swap_quick_sort(ARRAY & a, const ::function<
void(index, index) > & swap)
93 index_array stackLowerBound;
94 index_array stackUpperBound;
95 ::collection::index iLowerBound;
96 ::collection::index iUpperBound;
97 ::collection::index iLPos, iUPos, iMPos;
99 if (this->get_size() >= 2)
101 stackLowerBound.push(0);
102 stackUpperBound.push(this->get_size() - 1);
105 iLowerBound = stackLowerBound.pop();
106 iUpperBound = stackUpperBound.pop();
116 if (a.element_at(iMPos).case_insensitive_order(a.element_at(iUPos)) <= 0s)
120 a.swap(iMPos, iUPos);
133 if (a.element_at(iLPos).case_insensitive_order(a.element_at(iMPos)) <= 0)
137 a.swap(iLPos, iMPos);
146 if (iLowerBound < iMPos - 1)
148 stackLowerBound.push(iLowerBound);
149 stackUpperBound.push(iMPos - 1);
151 if (iMPos + 1 < iUpperBound)
153 stackLowerBound.push(iMPos + 1);
154 stackUpperBound.push(iUpperBound);
156 if (stackLowerBound.get_size() == 0)
164 template < prototype_array ARRAY, prototype_array INDEX_ARRAY >
165 void case_insensitive_get_quick_sort(ARRAY & a, INDEX_ARRAY & ia)
168 INDEX_ARRAY stackLowerBound;
169 INDEX_ARRAY stackUpperBound;
170 ::collection::index iLowerBound;
171 ::collection::index iUpperBound;
172 ::collection::index iLPos,iUPos,iMPos;
174 ::acme::array::append_sequence(ia,(::collection::index)0,(::collection::index)get_upper_bound());
175 if(this->get_size() >= 2)
177 stackLowerBound.push(0);
178 stackUpperBound.push(this->get_size() - 1);
181 iLowerBound = stackLowerBound.pop();
182 iUpperBound = stackUpperBound.pop();
192 if(a.element_at(ia[iMPos]).case_insensitive_order(a.element_at(ia[iUPos])) <= 0)
196 ia.swap(iMPos, iUPos);
208 if(a.element_at(ia[iLPos]).case_insensitive_order(a.element_at(ia[iMPos])) <= 0)
212 ia.swap(iLPos, iMPos);
220 if(iLowerBound < iMPos - 1)
222 stackLowerBound.push(iLowerBound);
223 stackUpperBound.push(iMPos - 1);
225 if(iMPos + 1 < iUpperBound)
227 stackLowerBound.push(iMPos + 1);
228 stackUpperBound.push(iUpperBound);
230 if(stackLowerBound.get_size() == 0)