Blender
V5.0
source
blender
blenlib
intern
sort_utils.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2013 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11
#include "
BLI_sort_utils.h
"
/* own include */
12
13
struct
SortAnyByFloat
{
14
float
sort_value
;
15
};
16
17
struct
SortAnyByInt
{
18
int
sort_value
;
19
};
20
21
struct
SortAnyByPtr
{
22
const
void
*
sort_value
;
23
};
24
25
int
BLI_sortutil_cmp_float
(
const
void
*a_,
const
void
*b_)
26
{
27
const
SortAnyByFloat
*a =
static_cast<
const
SortAnyByFloat
*
>
(a_);
28
const
SortAnyByFloat
*
b
=
static_cast<
const
SortAnyByFloat
*
>
(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
39
int
BLI_sortutil_cmp_float_reverse
(
const
void
*a_,
const
void
*b_)
40
{
41
const
SortAnyByFloat
*a =
static_cast<
const
SortAnyByFloat
*
>
(a_);
42
const
SortAnyByFloat
*
b
=
static_cast<
const
SortAnyByFloat
*
>
(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
53
int
BLI_sortutil_cmp_int
(
const
void
*a_,
const
void
*b_)
54
{
55
const
SortAnyByInt
*a =
static_cast<
const
SortAnyByInt
*
>
(a_);
56
const
SortAnyByInt
*
b
=
static_cast<
const
SortAnyByInt
*
>
(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
67
int
BLI_sortutil_cmp_int_reverse
(
const
void
*a_,
const
void
*b_)
68
{
69
const
SortAnyByInt
*a =
static_cast<
const
SortAnyByInt
*
>
(a_);
70
const
SortAnyByInt
*
b
=
static_cast<
const
SortAnyByInt
*
>
(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
}
BLI_sort_utils.h
b
b
Definition
compositor_morphological_distance_infos.hh:24
BLI_sortutil_cmp_int_reverse
int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
Definition
sort_utils.cc:67
BLI_sortutil_cmp_int
int BLI_sortutil_cmp_int(const void *a_, const void *b_)
Definition
sort_utils.cc:53
BLI_sortutil_cmp_float
int BLI_sortutil_cmp_float(const void *a_, const void *b_)
Definition
sort_utils.cc:25
BLI_sortutil_cmp_float_reverse
int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
Definition
sort_utils.cc:39
SortAnyByFloat
Definition
sort_utils.cc:13
SortAnyByFloat::sort_value
float sort_value
Definition
sort_utils.cc:14
SortAnyByInt
Definition
sort_utils.cc:17
SortAnyByInt::sort_value
int sort_value
Definition
sort_utils.cc:18
SortAnyByPtr
Definition
sort_utils.cc:21
SortAnyByPtr::sort_value
const void * sort_value
Definition
sort_utils.cc:22
Generated on
for Blender by
doxygen
1.16.1