AceSorting  1.0.0
Sorting algorithms for Arduino including Bubble Sort, Insertion Sort, Selection Sort, Shell Sort (3 versions), Comb Sort (4 versions), Quick Sort (3 versions)
Macros | Functions
selectionSort.h File Reference
#include "swap.h"
Include dependency graph for selectionSort.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ACE_SORTING_DIRECT_SELECTION_SORT   0
 If set to 1, use the direct inlined implementation of the 2-argument selectionSort(). More...
 

Functions

template<typename T >
void ace_sorting::selectionSort (T data[], uint16_t n)
 Selection sort. More...
 
template<typename T , typename F >
void ace_sorting::selectionSort (T data[], uint16_t n, F &&lessThan)
 Same as the 2-argument selectionSort() with the addition of a lessThan lambda expression or function. More...
 

Detailed Description

Selection sort. See https://en.wikipedia.org/wiki/Selection_sort

Definition in file selectionSort.h.

Macro Definition Documentation

◆ ACE_SORTING_DIRECT_SELECTION_SORT

#define ACE_SORTING_DIRECT_SELECTION_SORT   0

If set to 1, use the direct inlined implementation of the 2-argument selectionSort().

Otherwise, use the 3-argument selectionSort() to implement 2-argument selectionSort(). For selectionSort(), the compiler will optimize both versions to be identical.

Definition at line 46 of file selectionSort.h.

Function Documentation

◆ selectionSort() [1/2]

template<typename T >
void ace_sorting::selectionSort ( data[],
uint16_t  n 
)

Selection sort.

Average complexity: O(n^2) See https://en.wikipedia.org/wiki/Selection_sort

Template Parameters
Ttype of data to sort

Definition at line 89 of file selectionSort.h.

◆ selectionSort() [2/2]

template<typename T , typename F >
void ace_sorting::selectionSort ( data[],
uint16_t  n,
F &&  lessThan 
)

Same as the 2-argument selectionSort() with the addition of a lessThan lambda expression or function.

Template Parameters
Ttype of data to sort
Ftype of lambda expression or function that returns true if a < b

Definition at line 105 of file selectionSort.h.