CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Common/sorting.h
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
16
/*
17
in-place insertion sort for small arrays of data. This is O(n) if
18
already sorted and O(n^2) for worst case (elements are reversed)
19
sort order is smallest first
20
*/
21
void insertion_sort_uint16(uint16_t *data, uint16_t n);
22
23
/*
24
remove duplicates from a sorted uint16_t array, returning the new
25
count
26
*/
27
uint16_t remove_duplicates_uint16(uint16_t *data, uint16_t n);
28
29
/*
30
bisection search on a sorted uint16_t array to find an element
31
return true if found
32
*/
33
bool bisect_search_uint16(const uint16_t *data, uint16_t n, uint16_t value);
34
35
/*
36
remove elements in a 2nd sorted array from a sorted uint16_t array
37
return the number of remaining elements
38
*/
39
uint16_t remove_list_uint16(uint16_t *data, uint16_t n, const uint16_t *rem, uint16_t n2);
40
41
/*
42
return number of common elements between two sorted uint16_t lists
43
*/
44
uint16_t common_list_uint16(uint16_t *data, uint16_t n, const uint16_t *rem, uint16_t n2);
45
46