data_structures
array_to_queue.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* array_to_queue.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/22 15:20:39 by unite #+# #+# */
10 /* Updated: 2020/09/07 20:02:22 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "array.h"
15 
17 {
18  t_queue *queue;
19  size_t i;
20 
21  queue = queue_new(array->type);
22  i = 0;
23  while (i < array->size)
24  {
25  queue_enqueue(queue, array->arr[i]);
26  i++;
27  }
28  return (queue);
29 }
array.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
array_to_queue
t_queue * array_to_queue(const t_array *array)
Returns a queue that contains copies of the element in this array.
Definition: array_to_queue.c:16
s_array::type
const t_type * type
The type of items in this array.
Definition: array.h:52
s_array::arr
void ** arr
The data.
Definition: array.h:51
s_array
A resizable array.
Definition: array.h:47
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