1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#ifndef UTILS_UTILITIES_H
#define UTILS_UTILITIES_H
#include <stdlib.h>
#include <stdbool.h>
/*
* 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
|