-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
83 lines (76 loc) · 2.89 KB
/
Copy pathmain.c
File metadata and controls
83 lines (76 loc) · 2.89 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
72
73
74
75
76
77
78
79
80
81
82
83
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#define HT_IMP
#define HT_MACRO
#include "ht.h"
#define LIGHTGRAY { 200, 200, 200, 255 } // Light Gray
#define GRAY { 130, 130, 130, 255 } // Gray
#define DARKGRAY { 80, 80, 80, 255 } // Dark Gray
#define YELLOW { 253, 249, 0, 255 } // Yellow
#define GOLD { 255, 203, 0, 255 } // Gold
#define ORANGE { 255, 161, 0, 255 } // Orange
#define PINK { 255, 109, 194, 255 } // Pink
#define RED { 230, 41, 55, 255 } // Red
#define MAROON { 190, 33, 55, 255 } // Maroon
#define GREEN { 0, 228, 48, 255 } // Green
#define LIME { 0, 158, 47, 255 } // Lime
#define DARKGREEN { 0, 117, 44, 255 } // Dark Green
#define SKYBLUE { 102, 191, 255, 255 } // Sky Blue
#define BLUE { 0, 121, 241, 255 } // Blue
#define DARKBLUE { 0, 82, 172, 255 } // Dark Blue
#define PURPLE { 200, 122, 255, 255 } // Purple
#define VIOLET { 135, 60, 190, 255 } // Violet
#define DARKPURPLE { 112, 31, 126, 255 } // Dark Purple
#define BEIGE { 211, 176, 131, 255 } // Beige
#define BROWN { 127, 106, 79, 255 } // Brown
#define DARKBROWN { 76, 63, 47, 255 } // Dark Brown
#define BLACK { 0, 0, 0, 0,}
typedef struct{
char r;
char g;
char b;
char alpha;
}Color;
int main(){
new_ht(ht_1, 30);
Color gray = GRAY;
Color brown = BROWN;
Color violet = VIOLET;
Color maroon = MAROON;
Color black = BLACK;
ht_push(ht_1, "gray", Color, gray);
ht_push(ht_1, "brown", Color, brown);
ht_push(ht_1, "violet", Color, violet);
ht_push(ht_1, "violet2", Color, violet);
ht_push(ht_1, "maroon", Color, maroon);
ht_push(ht_1, "black", Color, black);
ht_print(ht_1);
printf("Checking if 'maroon' is present: %s\n", ht_exist(ht_1, "maroon") ? "true" : "false");
printf("Checking if 'darkpurple' is present: %s\n", ht_exist(ht_1, "darkpurple") ? "true" : "false");
printf("Checking if 'black' is present: %s\n", ht_exist(ht_1, "black") ? "true" : "false");
printf("Testing get function\n");
Color g = {0};
ht_get(ht_1, "gray", Color, g);
printf("Color 'gray': %d %d %d %d\n", g.r, g.g, g.b, g.alpha);
ht_get(ht_1, "black", Color, g);
printf("Color 'black': %d %d %d %d\n", g.r, g.g, g.b, g.alpha);
ht_free(ht_1);
ht_push(ht_1, "sky", int, 10);
ht_push(ht_1, "clear", int, 24);
ht_push(ht_1, "pristine", int, 32);
ht_push(ht_1, "pure", int, 69);
ht_push(ht_1, "sea", int, 420);
ht_print(ht_1);
printf("Checking if 'pristine' is present: %s\n", ht_exist(ht_1, "pristine") ? "true" : "false");
printf("Checking if 'darkpurple' is present: %s\n", ht_exist(ht_1, "darkpurple") ? "true" : "false");
printf("Testing get fucntion\n");
int data = 0;
ht_get(ht_1, "sky", int, data);
printf("Content of element 'sky': %d\n", data);
ht_get(ht_1, "sea", int, data);
printf("Content of element 'sea': %d\n", data);
ht_free(ht_1);
return 0;
}