BLI_sort_utils.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2013 Blender Foundation.
  19. * All rights reserved.
  20. *
  21. * ***** END GPL LICENSE BLOCK *****
  22. */
  23. #ifndef __BLI_SORT_UTILS_H__
  24. #define __BLI_SORT_UTILS_H__
  25. /** \file BLI_sort_utils.h
  26. * \ingroup bli
  27. */
  28. /**
  29. * \note keep \a sort_value first,
  30. * so cmp functions can be reused.
  31. */
  32. struct SortPointerByFloat {
  33. float sort_value;
  34. void *data;
  35. };
  36. struct SortIntByFloat {
  37. float sort_value;
  38. int data;
  39. };
  40. struct SortPointerByInt {
  41. int sort_value;
  42. void *data;
  43. };
  44. struct SortIntByInt {
  45. int sort_value;
  46. int data;
  47. };
  48. int BLI_sortutil_cmp_float(const void *a_, const void *b_);
  49. int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_);
  50. int BLI_sortutil_cmp_int(const void *a_, const void *b_);
  51. int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_);
  52. #endif /* __BLI_SORT_UTILS_H__ */