#ifndef UTILS_UTILITIES_H #define UTILS_UTILITIES_H #include #include /* * Compare the part a before a_until and * the part b before b_until */ int cmpstr_tillchar(const char *a, const char *b, char a_until, char b_until); //int cmpstr_tillindex(const char *a, const char *b, int a_until, int b_until); void shuffle(void *base, size_t nitems, size_t size); void init2d(void **array, size_t width, size_t height, size_t size); size_t sizeof_2d(size_t width, size_t height, size_t size); /* * Find the first integer numbers from the left and the right * and sets the pointers *left, *right to the first digit of * left and right numbers respectively. */ int find_lr_ints(char *text, char **left, char **right); /* * Returns ture, if * a <= b <= c OR * a >= b >= c */ inline bool monotonic(int a, int b, int c) { if (a <= b && b <= c) return true; if (a >= b && b >= c) return true; return false; } #endif