mirror of
https://github.com/theoludwig/libcproject.git
synced 2024-11-08 22:31:31 +01:00
refactor: usage of hash_map
instead of dictionary
This commit is contained in:
parent
4a11a096fa
commit
256e9cb690
@ -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 has_unique = true;
|
||||
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++) {
|
||||
char character = string_value[index];
|
||||
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;
|
||||
} else {
|
||||
dictionary_add(characters_already_seen, key, (void*)true);
|
||||
hash_map_add(characters_already_seen, key, (void*)true);
|
||||
}
|
||||
}
|
||||
return has_unique;
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "character.h"
|
||||
#include "convert.h"
|
||||
#include "dictionary.h"
|
||||
#include "hash_map.h"
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user