21 namespace perception {
26 inline bool ILess(
const T &a,
const T &b) {
32 inline bool ILarger(
const T &a,
const T &b) {
37 inline T
IMedian3(
const T &a,
const T &b,
const T &c) {
57 template <
typename T,
bool Compare(const T &, const T &)>
61 for (i = 1; i < n; i++) {
63 for (j = i; j > 0; j--) {
64 if (Compare(a[j - 1], tmp)) {
67 IMove(a[j - 1], &a[j]);
81 int nr_indexed_elements,
82 bool is_sort_indices =
true) {
84 if (is_sort_indices) {
85 IInsertionSort<int, ILess>(indices, nr_indexed_elements);
88 int j =
IMin(n, nr_indexed_elements);
89 int m =
IMin(n, nr_indexed_elements);
90 for (
int i = 0; i < m; ++i) {
93 ISwap(a + i * element_size, a + j * element_size, element_size);
106 template <
typename T>
108 int element_size_b,
int nr_indexed_elements,
109 bool is_sort_indices =
true) {
114 if (is_sort_indices) {
115 IInsertionSort<int, ILess>(indices, nr_indexed_elements);
118 int j =
IMin(n, nr_indexed_elements);
119 int m =
IMin(n, nr_indexed_elements);
120 for (
int i = 0; i < m; ++i) {
123 ISwap(a + i * element_size_a, a + j * element_size_a, element_size_a);
125 ISwap(b + i * element_size_b, b + j * element_size_b, element_size_b);
void IMove(const T &a, T *b)
Definition: i_basic.h:566
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
T IMedian3(const T &a, const T &b, const T &c)
Definition: i_sort.h:37
void IInsertionSort(T *a, int n)
Definition: i_sort.h:58
bool ILarger(const T &a, const T &b)
Definition: i_sort.h:32
void ISwap(T &a, T &b)
Definition: i_basic.h:299
bool ILess(const T &a, const T &b)
Definition: i_sort.h:26
T IMin(T a, T b)
Definition: i_basic.h:155
void IIndexedShuffle(T *a, int *indices, int n, int element_size, int nr_indexed_elements, bool is_sort_indices=true)
Definition: i_sort.h:80