1
1
mirror of https://github.com/theoludwig/libcproject.git synced 2024-12-11 21:13:00 +01:00

refactor: usage of hash_map instead of dictionary

This commit is contained in:
Théo LUDWIG 2023-06-25 19:32:50 +02:00
parent 4a11a096fa
commit 256e9cb690
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
2 changed files with 4 additions and 4 deletions

View File

@ -243,14 +243,14 @@ string_t string_concatenate(string_t string1, string_t string2) {
bool string_get_has_unique_characters(const string_t string_value) { bool string_get_has_unique_characters(const string_t string_value) {
bool has_unique = true; bool has_unique = true;
size_t string_length = string_get_length(string_value); size_t string_length = string_get_length(string_value);
struct dictionary* characters_already_seen = dictionary_initialization(); struct hash_map* characters_already_seen = hash_map_initialization();
for (size_t index = 0; index < string_length && has_unique; index++) { for (size_t index = 0; index < string_length && has_unique; index++) {
char character = string_value[index]; char character = string_value[index];
string_t key = convert_character_to_string(character); string_t key = convert_character_to_string(character);
if (dictionary_contains_key(characters_already_seen, key)) { if (hash_map_contains_key(characters_already_seen, key)) {
has_unique = false; has_unique = false;
} else { } else {
dictionary_add(characters_already_seen, key, (void*)true); hash_map_add(characters_already_seen, key, (void*)true);
} }
} }
return has_unique; return has_unique;

View File

@ -7,7 +7,7 @@
#include "character.h" #include "character.h"
#include "convert.h" #include "convert.h"
#include "dictionary.h" #include "hash_map.h"
#include "types.h" #include "types.h"
/** /**