cmp.h

Exposes comparator functions.

  • Author: Edward Jones
  • Date: 2021-09-17

Source file

CMP_SIG

Compare float.

  • Param v1: A float to compare
  • Param v2: Another float to compare
CMP_SIG(float);

CMP_SIG

Compare strings.

  • Param v1: A string to compare
  • Param v2: Another string to compare
CMP_SIG(str);

CMP_SIG

Compare ints.

  • Param v1: An int to compare
  • Param v2: Another int to compare
CMP_SIG(int);

CMP_SIG

Compare size_ts.

  • Param v1: A size_t to compare
  • Param v2: Another size_t to compare
CMP_SIG(size_t);

CMP_SIG

Compare doubles.

  • Param v1: A double to compare
  • Param v2: Another double to compare
CMP_SIG(double);

CMP_SIG

The signature of a comparator.

  • Param name: The name of the comparison functino

Returns: The signature of the comparison function for names

#	define CMP_SIG(name) Cmp cmp_##name##s(void* v1, void* v2)

CMP_SIG

Compare characters.

  • Param v1: A character to compare
  • Param v2: Another character to compare
CMP_SIG(char);

CMP_SIG

Compare void pointer. This compares the numerical value of the pointers, not their content!

  • Param v1: A void pointer to compare
  • Param v2: Another void pointer to compare
CMP_SIG(ptr);

Cmp

Type of a function which compares two values.

  • Param v1: A value to compare
  • Param v2: Another value to compare

Returns: The comparison result of v1 against v2

typedef Cmp(fun Comparator)(void* v1, void* v2);

streq

Check if two C-strings are equal (to improve readability with strcmp).

  • Param s: Pointer to a string to check
  • Param t: Pointer to a string to check

Returns: true if the strings are equal, false otherwise

bool streq(char const* s, char const* t);