diff options
Diffstat (limited to 'source/blender/blenlib/intern/sort_utils.c')
-rw-r--r-- | source/blender/blenlib/intern/sort_utils.c | 104 |
1 files changed, 70 insertions, 34 deletions
diff --git a/source/blender/blenlib/intern/sort_utils.c b/source/blender/blenlib/intern/sort_utils.c index 3220f753397..09babd3d424 100644 --- a/source/blender/blenlib/intern/sort_utils.c +++ b/source/blender/blenlib/intern/sort_utils.c @@ -23,70 +23,106 @@ * Utility functions for sorting common types. */ -#include "BLI_sort_utils.h" /* own include */ +#include "BLI_sort_utils.h" /* own include */ struct SortAnyByFloat { - float sort_value; + float sort_value; }; struct SortAnyByInt { - int sort_value; + int sort_value; }; struct SortAnyByPtr { - const void *sort_value; + const void *sort_value; }; int BLI_sortutil_cmp_float(const void *a_, const void *b_) { - const struct SortAnyByFloat *a = a_; - const struct SortAnyByFloat *b = b_; - if (a->sort_value > b->sort_value) { return 1; } - else if (a->sort_value < b->sort_value) { return -1; } - else { return 0; } + const struct SortAnyByFloat *a = a_; + const struct SortAnyByFloat *b = b_; + if (a->sort_value > b->sort_value) { + return 1; + } + else if (a->sort_value < b->sort_value) { + return -1; + } + else { + return 0; + } } int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_) { - const struct SortAnyByFloat *a = a_; - const struct SortAnyByFloat *b = b_; - if (a->sort_value < b->sort_value) { return 1; } - else if (a->sort_value > b->sort_value) { return -1; } - else { return 0; } + const struct SortAnyByFloat *a = a_; + const struct SortAnyByFloat *b = b_; + if (a->sort_value < b->sort_value) { + return 1; + } + else if (a->sort_value > b->sort_value) { + return -1; + } + else { + return 0; + } } int BLI_sortutil_cmp_int(const void *a_, const void *b_) { - const struct SortAnyByInt *a = a_; - const struct SortAnyByInt *b = b_; - if (a->sort_value > b->sort_value) { return 1; } - else if (a->sort_value < b->sort_value) { return -1; } - else { return 0; } + const struct SortAnyByInt *a = a_; + const struct SortAnyByInt *b = b_; + if (a->sort_value > b->sort_value) { + return 1; + } + else if (a->sort_value < b->sort_value) { + return -1; + } + else { + return 0; + } } int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_) { - const struct SortAnyByInt *a = a_; - const struct SortAnyByInt *b = b_; - if (a->sort_value < b->sort_value) { return 1; } - else if (a->sort_value > b->sort_value) { return -1; } - else { return 0; } + const struct SortAnyByInt *a = a_; + const struct SortAnyByInt *b = b_; + if (a->sort_value < b->sort_value) { + return 1; + } + else if (a->sort_value > b->sort_value) { + return -1; + } + else { + return 0; + } } int BLI_sortutil_cmp_ptr(const void *a_, const void *b_) { - const struct SortAnyByPtr *a = a_; - const struct SortAnyByPtr *b = b_; - if (a->sort_value > b->sort_value) { return 1; } - else if (a->sort_value < b->sort_value) { return -1; } - else { return 0; } + const struct SortAnyByPtr *a = a_; + const struct SortAnyByPtr *b = b_; + if (a->sort_value > b->sort_value) { + return 1; + } + else if (a->sort_value < b->sort_value) { + return -1; + } + else { + return 0; + } } int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_) { - const struct SortAnyByPtr *a = a_; - const struct SortAnyByPtr *b = b_; - if (a->sort_value < b->sort_value) { return 1; } - else if (a->sort_value > b->sort_value) { return -1; } - else { return 0; } + const struct SortAnyByPtr *a = a_; + const struct SortAnyByPtr *b = b_; + if (a->sort_value < b->sort_value) { + return 1; + } + else if (a->sort_value > b->sort_value) { + return -1; + } + else { + return 0; + } } |