Blender V4.3
sort_utils.c
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11#include "BLI_sort_utils.h" /* own include */
12
15};
16
19};
20
22 const void *sort_value;
23};
24
25int BLI_sortutil_cmp_float(const void *a_, const void *b_)
26{
27 const struct SortAnyByFloat *a = a_;
28 const struct SortAnyByFloat *b = b_;
29 if (a->sort_value > b->sort_value) {
30 return 1;
31 }
32 if (a->sort_value < b->sort_value) {
33 return -1;
34 }
35
36 return 0;
37}
38
39int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
40{
41 const struct SortAnyByFloat *a = a_;
42 const struct SortAnyByFloat *b = b_;
43 if (a->sort_value < b->sort_value) {
44 return 1;
45 }
46 if (a->sort_value > b->sort_value) {
47 return -1;
48 }
49
50 return 0;
51}
52
53int BLI_sortutil_cmp_int(const void *a_, const void *b_)
54{
55 const struct SortAnyByInt *a = a_;
56 const struct SortAnyByInt *b = b_;
57 if (a->sort_value > b->sort_value) {
58 return 1;
59 }
60 if (a->sort_value < b->sort_value) {
61 return -1;
62 }
63
64 return 0;
65}
66
67int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
68{
69 const struct SortAnyByInt *a = a_;
70 const struct SortAnyByInt *b = b_;
71 if (a->sort_value < b->sort_value) {
72 return 1;
73 }
74 if (a->sort_value > b->sort_value) {
75 return -1;
76 }
77
78 return 0;
79}
80
81int BLI_sortutil_cmp_ptr(const void *a_, const void *b_)
82{
83 const struct SortAnyByPtr *a = a_;
84 const struct SortAnyByPtr *b = b_;
85 if (a->sort_value > b->sort_value) {
86 return 1;
87 }
88 if (a->sort_value < b->sort_value) {
89 return -1;
90 }
91
92 return 0;
93}
94
95int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_)
96{
97 const struct SortAnyByPtr *a = a_;
98 const struct SortAnyByPtr *b = b_;
99 if (a->sort_value < b->sort_value) {
100 return 1;
101 }
102 if (a->sort_value > b->sort_value) {
103 return -1;
104 }
105
106 return 0;
107}
local_group_size(16, 16) .push_constant(Type b
int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
Definition sort_utils.c:67
int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_)
Definition sort_utils.c:95
int BLI_sortutil_cmp_int(const void *a_, const void *b_)
Definition sort_utils.c:53
int BLI_sortutil_cmp_float(const void *a_, const void *b_)
Definition sort_utils.c:25
int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
Definition sort_utils.c:39
int BLI_sortutil_cmp_ptr(const void *a_, const void *b_)
Definition sort_utils.c:81
const void * sort_value
Definition sort_utils.c:22