-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ (controller): Now allowing multiple implementations, added a root …
…controlller
- Loading branch information
Showing
24 changed files
with
587 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
set(COMMON_SRC | ||
hash.c | ||
key.c | ||
) | ||
|
||
set(COMMON_HEADERS | ||
hash.h | ||
key.h | ||
types.h | ||
) | ||
|
||
add_library(common_objects OBJECT ${COMMON_SRC}) | ||
|
||
install( | ||
FILES ${COMMON_HEADERS} | ||
DESTINATION include/${TINYHASH_NAME}/common | ||
) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,6 @@ | |
|
||
typedef void *th_any_t; | ||
|
||
typedef void *th_generic_table_t; | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
set(SEPARATE_CHAINING_SRC | ||
entry.c | ||
table.c | ||
) | ||
|
||
set(SEPARATE_CHAINING_HEADERS | ||
entry.h | ||
table.h | ||
) | ||
|
||
add_library(separate_chaining_objects OBJECT ${SEPARATE_CHAINING_SRC}) | ||
|
||
install( | ||
FILES ${SEPARATE_CHAINING_HEADERS} | ||
DESTINATION include/${TINYHASH_NAME}/separate_chaining | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "entry.h" | ||
|
||
static th_sc_entry_t *th_sc_entry_new(th_key_t *key, th_any_t value) | ||
{ | ||
th_sc_entry_t *entry = malloc(sizeof(th_sc_entry_t)); | ||
|
||
if (entry == NULL) return NULL; | ||
|
||
entry->key = *key; | ||
entry->value = value; | ||
entry->previous = NULL; | ||
entry->next = NULL; | ||
|
||
return entry; | ||
} | ||
|
||
static void th_sc_entry_raw_add(th_sc_entry_t **root, th_sc_entry_t *entry) | ||
{ | ||
if (*root != NULL) { | ||
(*root)->previous = entry; | ||
} | ||
|
||
entry->next = *root; | ||
*root = entry; | ||
} | ||
|
||
bool th_sc_entry_add(th_sc_entry_t **root, th_key_t *key, th_any_t value) | ||
{ | ||
th_sc_entry_t *entry = th_sc_entry_new(key, value); | ||
|
||
if (entry == NULL) return false; | ||
|
||
th_sc_entry_raw_add(root, entry); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef __TINYHASH_SC_ENTRY_H__ | ||
#define __TINYHASH_SC_ENTRY_H__ | ||
|
||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
#include "../common/hash.h" | ||
#include "../common/key.h" | ||
|
||
typedef struct th_sc_entry_s { | ||
th_key_t key; | ||
th_any_t value; | ||
struct th_sc_entry_s *previous; | ||
struct th_sc_entry_s *next; | ||
} th_sc_entry_t; | ||
|
||
|
||
bool th_sc_entry_add(th_sc_entry_t **root, th_key_t *key, th_any_t value); | ||
|
||
#endif |
Oops, something went wrong.