Blender
V5.3
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.hh
"
/* own include */
12
13
namespace
blender
{
14
15
struct
SortAnyByFloat
{
16
float
sort_value
;
17
};
18
19
struct
SortAnyByInt
{
20
int
sort_value
;
21
};
22
23
struct
SortAnyByPtr
{
24
const
void
*
sort_value
;
25
};
26
27
int
BLI_sortutil_cmp_float
(
const
void
*a_,
const
void
*b_)
28
{
29
const
SortAnyByFloat
*a =
static_cast<
const
SortAnyByFloat
*
>
(a_);
30
const
SortAnyByFloat
*
b
=
static_cast<
const
SortAnyByFloat
*
>
(b_);
31
if
(a->
sort_value
>
b
->sort_value) {
32
return
1;
33
}
34
if
(a->
sort_value
<
b
->sort_value) {
35
return
-1;
36
}
37
38
return
0;
39
}
40
41
int
BLI_sortutil_cmp_float_reverse
(
const
void
*a_,
const
void
*b_)
42
{
43
const
SortAnyByFloat
*a =
static_cast<
const
SortAnyByFloat
*
>
(a_);
44
const
SortAnyByFloat
*
b
=
static_cast<
const
SortAnyByFloat
*
>
(b_);
45
if
(a->
sort_value
<
b
->sort_value) {
46
return
1;
47
}
48
if
(a->
sort_value
>
b
->sort_value) {
49
return
-1;
50
}
51
52
return
0;
53
}
54
55
int
BLI_sortutil_cmp_int
(
const
void
*a_,
const
void
*b_)
56
{
57
const
SortAnyByInt
*a =
static_cast<
const
SortAnyByInt
*
>
(a_);
58
const
SortAnyByInt
*
b
=
static_cast<
const
SortAnyByInt
*
>
(b_);
59
if
(a->
sort_value
>
b
->sort_value) {
60
return
1;
61
}
62
if
(a->
sort_value
<
b
->sort_value) {
63
return
-1;
64
}
65
66
return
0;
67
}
68
69
int
BLI_sortutil_cmp_int_reverse
(
const
void
*a_,
const
void
*b_)
70
{
71
const
SortAnyByInt
*a =
static_cast<
const
SortAnyByInt
*
>
(a_);
72
const
SortAnyByInt
*
b
=
static_cast<
const
SortAnyByInt
*
>
(b_);
73
if
(a->
sort_value
<
b
->sort_value) {
74
return
1;
75
}
76
if
(a->
sort_value
>
b
->sort_value) {
77
return
-1;
78
}
79
80
return
0;
81
}
82
83
}
// namespace blender
BLI_sort_utils.hh
b
b
Definition
compositor_morphological_distance_infos.hh:36
blender
BMesh Iterators.
Definition
ANIM_action.hh:30
blender::BLI_sortutil_cmp_float
int BLI_sortutil_cmp_float(const void *a_, const void *b_)
Definition
sort_utils.cc:27
blender::BLI_sortutil_cmp_int_reverse
int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
Definition
sort_utils.cc:69
blender::BLI_sortutil_cmp_float_reverse
int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
Definition
sort_utils.cc:41
blender::BLI_sortutil_cmp_int
int BLI_sortutil_cmp_int(const void *a_, const void *b_)
Definition
sort_utils.cc:55
blender::SortAnyByFloat
Definition
sort_utils.cc:15
blender::SortAnyByFloat::sort_value
float sort_value
Definition
sort_utils.cc:16
blender::SortAnyByInt
Definition
sort_utils.cc:19
blender::SortAnyByInt::sort_value
int sort_value
Definition
sort_utils.cc:20
blender::SortAnyByPtr
Definition
sort_utils.cc:23
blender::SortAnyByPtr::sort_value
const void * sort_value
Definition
sort_utils.cc:24
Generated on
for Blender by
doxygen
1.18.0