-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
72 lines (62 loc) · 1.79 KB
/
util.h
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
72
#pragma once
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
typedef struct Vector {
void** contents;
int size;
int capacity;
} Vector;
typedef struct Stack {
void** elements;
int top;
int capacity;
} Stack;
typedef struct StringPointerMapEntry {
char* key;
void* value;
struct StringPointerMapEntry* next;
} StringPointerMapEntry;
typedef struct StringMap {
int size;
int capacity;
StringPointerMapEntry** entries;
} StringMap;
typedef struct IntegerStack {
int* elements;
int top;
int capacity;
} IntegerStack;
typedef struct StringIntegerMapEntry {
char* key;
int value;
struct StringIntegerMapEntry* next;
} StringIntegerMapEntry;
typedef struct StringIntegerMap {
int size;
int capacity;
StringIntegerMapEntry** entries;
} StringIntegerMap;
Vector* buildVectorList();
Stack* buildStack();
IntegerStack* initializeIntegerStack();
StringMap* buildStringMap(int capacity);
StringIntegerMap* buildStringIntegerMap(int capacity);
char* readFile(const char* path);
void pushVector(Vector* vec, void* e);
void pushStack(Stack* stack, void* e);
void* topOfStack(Stack* stack);
void popStack(Stack* stack);
void pushIntegerStack(IntegerStack* stack, int e);
int topOfIntegerStack(IntegerStack* stack);
int calculateHash(const char* string);
void popIntegerStack(IntegerStack* stack);
void appendStringMap(StringMap* map, const char* key, void* value);
bool stringMapContains(StringMap* map, const char* key);
void* getStringMap(StringMap* map, const char* key);
void appendStringIntegerMap(StringIntegerMap* map, const char* key, int value);
bool stringIntegerMapContains(StringIntegerMap* map, const char* key);
int getIntegerMap(StringIntegerMap* map, const char* key);