-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
71 lines (51 loc) · 1.54 KB
/
utils.h
File metadata and controls
71 lines (51 loc) · 1.54 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef UTILS_H
#define UTILS_H
#include <stdbool.h>
#include "object.h"
// string hashtable stuff
#define TABLE_SIZE 211
#define EOS '\0'
int hashpjw( void* value ); // hash function on string types
// List utils
typedef struct ForEachOptions {
bool remove;
void* insert;
} ForEachOptions;
typedef struct ListPrintProperties {
char * startString;
char * separatorString;
char * endString;
} ListPrintProperties;
typedef struct MapPrintProperties {
char * startStringPair;
char * separatorStringPair;
char * endStringPair;
ListPrintProperties * listPrintProperties;
} MapPrintProperties;
typedef struct TreePrintProperties {
char * left;
char * right;
char * vertical;
char * horizontal;
} TreePrintProperties;
extern ListPrintProperties defaultPrintProperties;
extern MapPrintProperties defaultMapPrintProperties;
extern TreePrintProperties defaultTreePrintProperties;
void resetOptions (ForEachOptions * options);
typedef bool ForEach (ObjectType * objectType, int index, void * element, void** parameters, ForEachOptions* options);
// Misc
typedef struct Pair {
void* first;
void* second;
} Pair;
typedef struct Single {
void* element;
} Single;
int stringToInt(char * value);
char * intToString(int integer);
char * copyString(char * stringValue);
int getStringSize(char * stringValue);
void stringInsert(char * totalString, char * insertString, int startIndex);
char * stringTakeLast(char * totalString, int startInclusive);
char * stringTakeSubstring(char * totalString, int startInclusive, int endExclusize);
#endif // UTILS_H