aboutsummaryrefslogtreecommitdiff
path: root/src/utils/utilities.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/utilities.h')
-rw-r--r--src/utils/utilities.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/utils/utilities.h b/src/utils/utilities.h
new file mode 100644
index 0000000..9447c1f
--- /dev/null
+++ b/src/utils/utilities.h
@@ -0,0 +1,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 \ No newline at end of file