Skip to content

Commit 9c997f9

Browse files
committed
.clang-format
1 parent d2e6e1b commit 9c997f9

30 files changed

+3821
-4202
lines changed

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
BasedOnStyle: LLVM
2+
IndentWidth: 4
3+
UseTab: ForIndentation
4+
TabWidth: 4

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/.vs
2-
/out
2+
/out

CMakePresets.json

Lines changed: 99 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
11
{
2-
"version": 3,
3-
"configurePresets": [
4-
{
5-
"name": "windows-base",
6-
"hidden": true,
7-
"generator": "Ninja",
8-
"binaryDir": "${sourceDir}/out/build/${presetName}",
9-
"installDir": "${sourceDir}/out/install/${presetName}",
10-
"cacheVariables": {
11-
"CMAKE_C_COMPILER": "cl.exe",
12-
"CMAKE_CXX_COMPILER": "cl.exe"
13-
},
14-
"condition": {
15-
"type": "equals",
16-
"lhs": "${hostSystemName}",
17-
"rhs": "Windows"
18-
}
19-
},
20-
{
21-
"name": "x64-debug",
22-
"displayName": "x64 Debug",
23-
"inherits": "windows-base",
24-
"architecture": {
25-
"value": "x64",
26-
"strategy": "external"
27-
},
28-
"cacheVariables": {
29-
"CMAKE_BUILD_TYPE": "Debug"
30-
}
31-
},
32-
{
33-
"name": "x64-release",
34-
"displayName": "x64 Release",
35-
"inherits": "x64-debug",
36-
"cacheVariables": {
37-
"CMAKE_BUILD_TYPE": "Release"
38-
}
39-
},
40-
{
41-
"name": "x86-debug",
42-
"displayName": "x86 Debug",
43-
"inherits": "windows-base",
44-
"architecture": {
45-
"value": "x86",
46-
"strategy": "external"
47-
},
48-
"cacheVariables": {
49-
"CMAKE_BUILD_TYPE": "Debug"
50-
}
51-
},
52-
{
53-
"name": "x86-release",
54-
"displayName": "x86 Release",
55-
"inherits": "x86-debug",
56-
"cacheVariables": {
57-
"CMAKE_BUILD_TYPE": "Release"
58-
}
59-
},
60-
{
61-
"name": "linux-debug",
62-
"displayName": "Linux Debug",
63-
"generator": "Ninja",
64-
"binaryDir": "${sourceDir}/out/build/${presetName}",
65-
"installDir": "${sourceDir}/out/install/${presetName}",
66-
"cacheVariables": {
67-
"CMAKE_BUILD_TYPE": "Debug"
68-
},
69-
"condition": {
70-
"type": "equals",
71-
"lhs": "${hostSystemName}",
72-
"rhs": "Linux"
73-
},
74-
"vendor": {
75-
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
76-
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
77-
}
78-
}
79-
},
80-
{
81-
"name": "macos-debug",
82-
"displayName": "macOS Debug",
83-
"generator": "Ninja",
84-
"binaryDir": "${sourceDir}/out/build/${presetName}",
85-
"installDir": "${sourceDir}/out/install/${presetName}",
86-
"cacheVariables": {
87-
"CMAKE_BUILD_TYPE": "Debug"
88-
},
89-
"condition": {
90-
"type": "equals",
91-
"lhs": "${hostSystemName}",
92-
"rhs": "Darwin"
93-
},
94-
"vendor": {
95-
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
96-
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
97-
}
98-
}
99-
}
100-
]
2+
"version": 3,
3+
"configurePresets": [
4+
{
5+
"name": "windows-base",
6+
"hidden": true,
7+
"generator": "Ninja",
8+
"binaryDir": "${sourceDir}/out/build/${presetName}",
9+
"installDir": "${sourceDir}/out/install/${presetName}",
10+
"cacheVariables": {
11+
"CMAKE_C_COMPILER": "cl.exe",
12+
"CMAKE_CXX_COMPILER": "cl.exe"
13+
},
14+
"condition": {
15+
"type": "equals",
16+
"lhs": "${hostSystemName}",
17+
"rhs": "Windows"
18+
}
19+
},
20+
{
21+
"name": "x64-debug",
22+
"displayName": "x64 Debug",
23+
"inherits": "windows-base",
24+
"architecture": {
25+
"value": "x64",
26+
"strategy": "external"
27+
},
28+
"cacheVariables": {
29+
"CMAKE_BUILD_TYPE": "Debug"
30+
}
31+
},
32+
{
33+
"name": "x64-release",
34+
"displayName": "x64 Release",
35+
"inherits": "x64-debug",
36+
"cacheVariables": {
37+
"CMAKE_BUILD_TYPE": "Release"
38+
}
39+
},
40+
{
41+
"name": "x86-debug",
42+
"displayName": "x86 Debug",
43+
"inherits": "windows-base",
44+
"architecture": {
45+
"value": "x86",
46+
"strategy": "external"
47+
},
48+
"cacheVariables": {
49+
"CMAKE_BUILD_TYPE": "Debug"
50+
}
51+
},
52+
{
53+
"name": "x86-release",
54+
"displayName": "x86 Release",
55+
"inherits": "x86-debug",
56+
"cacheVariables": {
57+
"CMAKE_BUILD_TYPE": "Release"
58+
}
59+
},
60+
{
61+
"name": "linux-debug",
62+
"displayName": "Linux Debug",
63+
"generator": "Ninja",
64+
"binaryDir": "${sourceDir}/out/build/${presetName}",
65+
"installDir": "${sourceDir}/out/install/${presetName}",
66+
"cacheVariables": {
67+
"CMAKE_BUILD_TYPE": "Debug"
68+
},
69+
"condition": {
70+
"type": "equals",
71+
"lhs": "${hostSystemName}",
72+
"rhs": "Linux"
73+
},
74+
"vendor": {
75+
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
76+
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
77+
}
78+
}
79+
},
80+
{
81+
"name": "macos-debug",
82+
"displayName": "macOS Debug",
83+
"generator": "Ninja",
84+
"binaryDir": "${sourceDir}/out/build/${presetName}",
85+
"installDir": "${sourceDir}/out/install/${presetName}",
86+
"cacheVariables": {
87+
"CMAKE_BUILD_TYPE": "Debug"
88+
},
89+
"condition": {
90+
"type": "equals",
91+
"lhs": "${hostSystemName}",
92+
"rhs": "Darwin"
93+
},
94+
"vendor": {
95+
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
96+
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
97+
}
98+
}
99+
}
100+
]
101101
}

DataStructures/Common/Node.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
#include <string.h>
55

6-
struct Node node_constructor(void* data, int size)
7-
{
8-
if (size < 1)
9-
{
6+
struct Node node_constructor(void *data, int size) {
7+
if (size < 1) {
108
printf("Invalid data size for node...\n");
119
exit(1);
1210
}
@@ -18,8 +16,7 @@ struct Node node_constructor(void* data, int size)
1816
return node;
1917
}
2018

21-
void node_destructor(struct Node* node)
22-
{
19+
void node_destructor(struct Node *node) {
2320
free(node->data);
2421
free(node);
25-
}
22+
}

DataStructures/Common/Node.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
#ifndef Node_h
22
#define Node_h
33

4-
#include <stdlib.h>
5-
#include <stdint.h>
64
#include <stdbool.h>
5+
#include <stdint.h>
76
#include <stdio.h>
7+
#include <stdlib.h>
88

9-
struct Node
10-
{
11-
void* data;
12-
struct Node* prev;
13-
struct Node* next;
9+
struct Node {
10+
void *data;
11+
struct Node *prev;
12+
struct Node *next;
1413
};
1514

16-
struct Node node_constructor(void* data, int size);
17-
void node_destructor(struct Node* node);
15+
struct Node node_constructor(void *data, int size);
16+
void node_destructor(struct Node *node);
1817

19-
#endif // !Node_h
18+
#endif // !Node_h

DataStructures/Dictionary/Dictionary.c

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,53 @@
22
#include "Dictionary.h"
33
#include <string.h>
44

5-
void insert_dict(struct Dictionary* dictionary, void* key, int key_size, void* value, int value_size);
6-
void* search_dict(struct Dictionary* dictionary, void* key, int key_size);
5+
void insert_dict(struct Dictionary *dictionary, void *key, int key_size,
6+
void *value, int value_size);
7+
void *search_dict(struct Dictionary *dictionary, void *key, int key_size);
78

8-
struct Dictionary dictionary_constructor(int (*compare)(void* key_1, void* key_2))
9-
{
9+
struct Dictionary dictionary_constructor(int (*compare)(void *key_1,
10+
void *key_2)) {
1011
struct Dictionary dictionary;
1112
dictionary.binary_search_tree = binary_search_tree_constructor(compare);
1213
dictionary.insert = insert_dict;
1314
dictionary.search = search_dict;
1415
return dictionary;
1516
}
1617

17-
void dictionary_destructor(struct Dictionary* dictionary)
18-
{
18+
void dictionary_destructor(struct Dictionary *dictionary) {
1919
binary_search_tree_destructor(&dictionary->binary_search_tree);
2020
}
2121

22-
void* search_dict(struct Dictionary* dictionary, void* key, int key_size)
23-
{
22+
void *search_dict(struct Dictionary *dictionary, void *key, int key_size) {
2423
int dummy_value = 0;
25-
struct Entry searchable = entry_constructor(key, key_size, &dummy_value, sizeof(dummy_value));
26-
void* result =
27-
dictionary->binary_search_tree
28-
.search(&dictionary->binary_search_tree, &searchable, sizeof(searchable));
29-
if (result)
30-
{
31-
return ((struct Entry*)result)->value;
32-
}
33-
else
34-
{
24+
struct Entry searchable =
25+
entry_constructor(key, key_size, &dummy_value, sizeof(dummy_value));
26+
void *result = dictionary->binary_search_tree.search(
27+
&dictionary->binary_search_tree, &searchable, sizeof(searchable));
28+
if (result) {
29+
return ((struct Entry *)result)->value;
30+
} else {
3531
return NULL;
3632
}
3733
}
3834

39-
40-
void insert_dict(struct Dictionary* dictionary, void* key, int key_size, void* value, int value_size)
41-
{
35+
void insert_dict(struct Dictionary *dictionary, void *key, int key_size,
36+
void *value, int value_size) {
4237
struct Entry entry = entry_constructor(key, key_size, value, value_size);
4338

44-
dictionary->binary_search_tree.insert(&dictionary->binary_search_tree, &entry, sizeof(entry));
45-
39+
dictionary->binary_search_tree.insert(&dictionary->binary_search_tree,
40+
&entry, sizeof(entry));
4641
}
4742

4843
// MARK: PUBLIC HELPER FUNCTIONS
49-
int compare_string_keys(void* entry_1, void* entry_2)
50-
{
51-
if (strcmp((char*)((struct Entry*)entry_1)->key, (char*)((struct Entry*)entry_2)->key) > 0)
52-
{
44+
int compare_string_keys(void *entry_1, void *entry_2) {
45+
if (strcmp((char *)((struct Entry *)entry_1)->key,
46+
(char *)((struct Entry *)entry_2)->key) > 0) {
5347
return 1;
54-
}
55-
else if (strcmp((char*)((struct Entry*)entry_1)->key, (char*)((struct Entry*)entry_2)->key) < 0)
56-
{
48+
} else if (strcmp((char *)((struct Entry *)entry_1)->key,
49+
(char *)((struct Entry *)entry_2)->key) < 0) {
5750
return -1;
58-
}
59-
else
60-
{
51+
} else {
6152
return 0;
6253
}
63-
}
54+
}

DataStructures/Dictionary/Dictionary.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
#include "../Trees/BinarySearchTree.h"
55
#include "Entry.h"
66

7-
struct Dictionary
8-
{
7+
struct Dictionary {
98
struct BinarySearchTree binary_search_tree;
109

11-
void (*insert)(struct Dictionary* dictionary, void* key, int key_size, void* value, int value_size);
12-
void* (*search)(struct Dictionary* dictionary, void* key, int key_size);
10+
void (*insert)(struct Dictionary *dictionary, void *key, int key_size,
11+
void *value, int value_size);
12+
void *(*search)(struct Dictionary *dictionary, void *key, int key_size);
1313
};
1414

15-
struct Dictionary dictionary_constructor(int (*compare)(void* key_1, void* key_2));
16-
void dictionary_destructor(struct Dictionary* dictionary);
17-
int compare_string_keys(void* entry_1, void* entry_2);
15+
struct Dictionary dictionary_constructor(int (*compare)(void *key_1,
16+
void *key_2));
17+
void dictionary_destructor(struct Dictionary *dictionary);
18+
int compare_string_keys(void *entry_1, void *entry_2);
1819
#endif // !Dictionary_h

0 commit comments

Comments
 (0)