refine docs for compare.h - issue #548

Sat, 04 Jan 2025 16:10:53 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 04 Jan 2025 16:10:53 +0100
changeset 1092
8a35119d1f01
parent 1091
04a114799d9d
child 1093
bcbf6bf582fa

refine docs for compare.h - issue #548

src/cx/compare.h file | annotate | diff | comparison | revisions
--- a/src/cx/compare.h	Sat Jan 04 16:02:20 2025 +0100
+++ b/src/cx/compare.h	Sat Jan 04 16:10:53 2025 +0100
@@ -26,11 +26,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /**
- * \file compare.h
- * \brief A collection of simple compare functions.
- * \author Mike Becker
- * \author Olaf Wintermann
- * \copyright 2-Clause BSD License
+ * @file compare.h
+ * @brief A collection of simple compare functions.
+ * @author Mike Becker
+ * @author Olaf Wintermann
+ * @copyright 2-Clause BSD License
  */
 
 #ifndef UCX_COMPARE_H
@@ -56,18 +56,22 @@
  */
 cx_attr_nonnull
 cx_attr_nodiscard
-typedef int(*cx_compare_func)(
-        const void *left,
-        const void *right
+typedef int (*cx_compare_func)(
+    const void *left,
+    const void *right
 );
 
 /**
  * Compares two integers of type int.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to integer one
  * @param i2 pointer to integer two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -78,8 +82,9 @@
  *
  * @param i1 integer one
  * @param i2 integer two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_int(int i1, int i2);
@@ -87,10 +92,14 @@
 /**
  * Compares two integers of type long int.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to long integer one
  * @param i2 pointer to long integer two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -101,8 +110,9 @@
  *
  * @param i1 long integer one
  * @param i2 long integer two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_longint(long int i1, long int i2);
@@ -110,10 +120,14 @@
 /**
  * Compares two integers of type long long.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to long long one
  * @param i2 pointer to long long two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -124,8 +138,9 @@
  *
  * @param i1 long long int one
  * @param i2 long long int two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_longlong(long long int i1, long long int i2);
@@ -133,10 +148,14 @@
 /**
  * Compares two integers of type int16_t.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to int16_t one
  * @param i2 pointer to int16_t two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -147,8 +166,9 @@
  *
  * @param i1 int16_t one
  * @param i2 int16_t two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_int16(int16_t i1, int16_t i2);
@@ -156,10 +176,14 @@
 /**
  * Compares two integers of type int32_t.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to int32_t one
  * @param i2 pointer to int32_t two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -170,8 +194,9 @@
  *
  * @param i1 int32_t one
  * @param i2 int32_t two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_int32(int32_t i1, int32_t i2);
@@ -179,10 +204,14 @@
 /**
  * Compares two integers of type int64_t.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to int64_t one
  * @param i2 pointer to int64_t two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -193,8 +222,9 @@
  *
  * @param i1 int64_t one
  * @param i2 int64_t two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_int64(int64_t i1, int64_t i2);
@@ -202,10 +232,14 @@
 /**
  * Compares two integers of type unsigned int.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to unsigned integer one
  * @param i2 pointer to unsigned integer two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -216,8 +250,9 @@
  *
  * @param i1 unsigned integer one
  * @param i2 unsigned integer two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_uint(unsigned int i1, unsigned int i2);
@@ -225,10 +260,14 @@
 /**
  * Compares two integers of type unsigned long int.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to unsigned long integer one
  * @param i2 pointer to unsigned long integer two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -239,8 +278,9 @@
  *
  * @param i1 unsigned long integer one
  * @param i2 unsigned long integer two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_ulongint(unsigned long int i1, unsigned long int i2);
@@ -248,10 +288,14 @@
 /**
  * Compares two integers of type unsigned long long.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to unsigned long long one
  * @param i2 pointer to unsigned long long two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -262,8 +306,9 @@
  *
  * @param i1 unsigned long long one
  * @param i2 unsigned long long two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_ulonglong(unsigned long long int i1, unsigned long long int i2);
@@ -271,10 +316,14 @@
 /**
  * Compares two integers of type uint16_t.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to uint16_t one
  * @param i2 pointer to uint16_t two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -285,8 +334,9 @@
  *
  * @param i1 uint16_t one
  * @param i2 uint16_t two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_uint16(uint16_t i1, uint16_t i2);
@@ -294,10 +344,14 @@
 /**
  * Compares two integers of type uint32_t.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to uint32_t one
  * @param i2 pointer to uint32_t two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -308,8 +362,9 @@
  *
  * @param i1 uint32_t one
  * @param i2 uint32_t two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_uint32(uint32_t i1, uint32_t i2);
@@ -317,10 +372,14 @@
 /**
  * Compares two integers of type uint64_t.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param i1 pointer to uint64_t one
  * @param i2 pointer to uint64_t two
- * @return -1, if *i1 is less than *i2, 0 if both are equal,
- * 1 if *i1 is greater than *i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -331,8 +390,9 @@
  *
  * @param i1 uint64_t one
  * @param i2 uint64_t two
- * @return -1, if i1 is less than i2, 0 if both are equal,
- * 1 if i1 is greater than i2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_uint64(uint64_t i1, uint64_t i2);
@@ -340,10 +400,14 @@
 /**
  * Compares two real numbers of type float with precision 1e-6f.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param f1 pointer to float one
  * @param f2 pointer to float two
- * @return -1, if *f1 is less than *f2, 0 if both are equal,
- * 1 if *f1 is greater than *f2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -354,8 +418,9 @@
  *
  * @param f1 float one
  * @param f2 float two
- * @return -1, if f1 is less than f2, 0 if both are equal,
- * 1 if f1 is greater than f2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_float(float f1, float f2);
@@ -363,10 +428,14 @@
 /**
  * Compares two real numbers of type double with precision 1e-14.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param d1 pointer to double one
  * @param d2 pointer to double two
- * @return -1, if *d1 is less than *d2, 0 if both are equal,
- * 1 if *d1 is greater than *d2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -377,8 +446,9 @@
  *
  * @param d1 double one
  * @param d2 double two
- * @return -1, if d1 is less than d2, 0 if both are equal,
- * 1 if d1 is greater than d2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_double(double d1, double d2);
@@ -386,10 +456,14 @@
 /**
  * Compares the integer representation of two pointers.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param ptr1 pointer to pointer one (const intptr_t*)
  * @param ptr2 pointer to pointer two (const intptr_t*)
- * @return -1 if *ptr1 is less than *ptr2, 0 if both are equal,
- * 1 if *ptr1 is greater than *ptr2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -400,8 +474,9 @@
  *
  * @param ptr1 pointer one
  * @param ptr2 pointer two
- * @return -1 if ptr1 is less than ptr2, 0 if both are equal,
- * 1 if ptr1 is greater than ptr2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_intptr(intptr_t ptr1, intptr_t ptr2);
@@ -409,10 +484,14 @@
 /**
  * Compares the unsigned integer representation of two pointers.
  *
+ * @note the parameters deliberately have type @c void* to be
+ * compatible with #cx_compare_func without the need of a cast.
+ *
  * @param ptr1 pointer to pointer one (const uintptr_t*)
  * @param ptr2 pointer to pointer two (const uintptr_t*)
- * @return -1 if *ptr1 is less than *ptr2, 0 if both are equal,
- * 1 if *ptr1 is greater than *ptr2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -423,8 +502,9 @@
  *
  * @param ptr1 pointer one
  * @param ptr2 pointer two
- * @return -1 if ptr1 is less than ptr2, 0 if both are equal,
- * 1 if ptr1 is greater than ptr2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nodiscard
 int cx_vcmp_uintptr(uintptr_t ptr1, uintptr_t ptr2);
@@ -434,8 +514,9 @@
  *
  * @param ptr1 pointer one
  * @param ptr2 pointer two
- * @return -1 if ptr1 is less than ptr2, 0 if both are equal,
- * 1 if ptr1 is greater than ptr2
+ * @retval -1 if the left argument is less than the right argument
+ * @retval 0 if both arguments are equal
+ * @retval 1 if the left argument is greater than the right argument
  */
 cx_attr_nonnull
 cx_attr_nodiscard

mercurial