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