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
bubbleSort.h File Reference
#include "swap.h"
Include dependency graph for bubbleSort.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_BUBBLE_SORT   0
 If set to 1, use the direct inlined implementation of the 2-argument bubbleSort(). More...
 

Functions

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

Detailed Description

Bubble sort.

Definition in file bubbleSort.h.

Macro Definition Documentation

◆ ACE_SORTING_DIRECT_BUBBLE_SORT

#define ACE_SORTING_DIRECT_BUBBLE_SORT   0

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

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

Definition at line 43 of file bubbleSort.h.

Function Documentation

◆ bubbleSort() [1/2]

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

Bubble sort.

Average complexity: O(n^2)

Template Parameters
Ttype of data to sort

Definition at line 70 of file bubbleSort.h.

◆ bubbleSort() [2/2]

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

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