MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ execute_sorting_algorithm()

template<std::random_access_iterator Iterator, typename Comparator >
void MayaFlux::Yantra::execute_sorting_algorithm ( Iterator  begin,
Iterator  end,
Comparator  comp,
SortingAlgorithm  algorithm 
)

Execute sorting algorithm on iterator range.

Template Parameters
IteratorRandom access iterator type
ComparatorComparison function type
Parameters
beginStart iterator
endEnd iterator
compComparator function
algorithmAlgorithm to use

Definition at line 128 of file SortingHelper.hpp.

130{
131 switch (algorithm) {
132 case SortingAlgorithm::STANDARD:
133 std::ranges::sort(begin, end, comp);
134 break;
135
136 case SortingAlgorithm::STABLE:
137 std::ranges::stable_sort(begin, end, comp);
138 break;
139
140 case SortingAlgorithm::PARTIAL: {
141 if (std::distance(begin, end) > 1) {
142 auto middle = begin + std::distance(begin, end) / 2;
143 std::partial_sort(begin, middle, end, comp);
144 }
145 break;
146 }
147
148 case SortingAlgorithm::NTH_ELEMENT: {
149 if (std::distance(begin, end) > 1) {
150 auto middle = begin + std::distance(begin, end) / 2;
151 std::nth_element(begin, middle, end, comp);
152 }
153 break;
154 }
155
156 case SortingAlgorithm::HEAP: {
157 std::make_heap(begin, end, comp);
158 std::sort_heap(begin, end, comp);
159 break;
160 }
161
162 case SortingAlgorithm::PARALLEL:
163 MayaFlux::Parallel::sort(MayaFlux::Parallel::par_unseq, begin, end, comp);
164 break;
165
166 case SortingAlgorithm::RADIX:
167 case SortingAlgorithm::COUNTING:
168 case SortingAlgorithm::BUCKET:
169 case SortingAlgorithm::MERGE_EXTERNAL:
170 case SortingAlgorithm::QUICK_OPTIMIZED:
171 case SortingAlgorithm::LAZY_STREAMING:
172 case SortingAlgorithm::PREDICTIVE_ML:
173 case SortingAlgorithm::GPU_ACCELERATED:
174 // TODO: Implement specialized algorithms
175 default:
176 std::ranges::sort(begin, end, comp);
177 break;
178 }
179}

References BUCKET, COUNTING, GPU_ACCELERATED, HEAP, LAZY_STREAMING, MERGE_EXTERNAL, NTH_ELEMENT, PARALLEL, PARTIAL, PREDICTIVE_ML, QUICK_OPTIMIZED, RADIX, STABLE, and STANDARD.

Referenced by sort_span_inplace().

+ Here is the caller graph for this function: