data_structures
hashmap_vals.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* hashmap_vals.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/21 19:15:14 by unite #+# #+# */
10 /* Updated: 2020/09/07 20:19:25 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "hashmap.h"
15 
17 {
18  t_queue *queue;
19  size_t i;
20 
21  queue = queue_new(hm->val_type);
22  i = 0;
23  while (i < hm->capacity)
24  {
25  if (hm->vals[i] != NULL)
26  queue_enqueue(queue, hm->vals[i]);
27  i++;
28  }
29  return (queue);
30 }
hashmap_vals
t_queue * hashmap_vals(const t_hashmap *hm)
Returns a queue with all the values in the map.
Definition: hashmap_vals.c:16
hashmap.h
s_list
Doubly-linked list of generic items.
Definition: list.h:54
queue_new
t_queue * queue_new(const t_type *type)
Allocates memory and initializes an empty queue.
Definition: queue_new.c:16
s_hashmap
A symbol table of generic key-value pairs, implemented as a dynamically resizing linear-probing hashm...
Definition: hashmap.h:48
queue_enqueue
void queue_enqueue(t_queue *queue, const void *data)
Copies the item and adds the copy to the queue.
Definition: queue_enqueue.c:16
s_hashmap::val_type
const t_type * val_type
The type of values in the hashmap.
Definition: hashmap.h:55
s_hashmap::vals
void ** vals
The values.
Definition: hashmap.h:51