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)
All Files Functions Macros Pages
Macros | Functions
insertionSort.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

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

Functions

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

Detailed Description

Insertion sort. See https://en.wikipedia.org/wiki/Insertion_sort

Definition in file insertionSort.h.

Macro Definition Documentation

◆ ACE_SORTING_DIRECT_INSERTION_SORT

#define ACE_SORTING_DIRECT_INSERTION_SORT   0

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

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

Definition at line 42 of file insertionSort.h.

Function Documentation

◆ insertionSort() [1/2]

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

Insertion sort.

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

Template Parameters
Ttype of data to sort

Definition at line 76 of file insertionSort.h.

◆ insertionSort() [2/2]

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

Same as the 2-argument insertionSort() 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 92 of file insertionSort.h.