Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
Update adt_map.c
  • Loading branch information
viferga authored Feb 21, 2023
commit abfea4e1cf90061711fdc4acd8ef6fa456b588cd
64 changes: 44 additions & 20 deletions source/adt/source/adt_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,44 +253,68 @@ vector map_get(map m, map_key key)

vector map_get_keys(map m)
{
vector v = vector_create(sizeof(void *));
bucket b;
pair p;
for (size_t iterator = 0; iterator < m->capacity; iterator++)
if (m != NULL)
{
b = &m->buckets[iterator];
vector v = vector_create(sizeof(void *));

if (v == NULL)
{
return NULL;
}

if (b->pairs != NULL && b->count > 0)
for (size_t iterator = 0; iterator < m->capacity; iterator++)
{
for (size_t index = 0; index < b->count; index++)
bucket b = &m->buckets[iterator];

if (b->pairs != NULL && b->count > 0)
{
p = &b->pairs[index];
vector_push_back(v, &p->key);
size_t index;

for (index = 0; index < b->count; index++)
{
pair p = &b->pairs[index];
vector_push_back(v, &p->key);
}
}
}

return v;
}
return v;

return NULL;
}

vector map_get_values(map m)
{
vector v = vector_create(sizeof(void *));
bucket b;
pair p;
for (size_t iterator = 0; iterator < m->capacity; iterator++)
if (m != NULL)
{
b = &m->buckets[iterator];
vector v = vector_create(sizeof(void *));

if (v == NULL)
{
return NULL;
}

if (b->pairs != NULL && b->count > 0)
for (size_t iterator = 0; iterator < m->capacity; iterator++)
{
for (size_t index = 0; index < b->count; index++)
bucket b = &m->buckets[iterator];

if (b->pairs != NULL && b->count > 0)
{
p = &b->pairs[index];
vector_push_back(v, &p->value);
size_t index;

for (index = 0; index < b->count; index++)
{
pair p = &b->pairs[index];
vector_push_back(v, &p->value);
}
}
}

return v;
}
return v;

return NULL;
}

int map_contains(map m, map_key key)
Expand Down