data_structures
min_pq.h
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* min_pq.h :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/16 18:46:03 by unite #+# #+# */
10 /* Updated: 2020/09/07 22:19:04 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #ifndef MIN_PQ_H
15 
16 # define MIN_PQ_H
17 
18 # include <errno.h>
19 # include <sys/types.h>
20 # include "types.h"
21 # include "array.h"
22 # include "utils.h"
23 
29 typedef t_array t_min_pq;
30 
39 t_min_pq *min_pq_new(const t_type *type);
40 
46 void *min_pq_peek(const t_min_pq *pq);
47 
53 void *min_pq_pop(t_min_pq *pq);
54 
60 void min_pq_add(t_min_pq *pq, const void *data);
61 
67 size_t min_pq_size(const t_min_pq *pq);
68 
73 void min_pq_delete(t_min_pq *pq);
74 
80 t_min_pq *min_pq_copy(const t_min_pq *pq);
81 
82 #endif
min_pq_new
t_min_pq * min_pq_new(const t_type *type)
Initializes a new empty priority queue.
Definition: min_pq_new.c:16
min_pq_peek
void * min_pq_peek(const t_min_pq *pq)
Returns the smallest key in the queue.
Definition: min_pq_peek.c:16
types.h
min_pq_size
size_t min_pq_size(const t_min_pq *pq)
Returns the number of keys in this queue.
Definition: min_pq_size.c:16
array.h
utils.h
min_pq_add
void min_pq_add(t_min_pq *pq, const void *data)
Adds a copy of the specified element to the queue.
Definition: min_pq_add.c:30
s_type
A full representation of a data type, used to achieve polymorphism in the implementation of data stru...
Definition: types.h:47
s_array
A resizable array.
Definition: array.h:47
t_min_pq
t_array t_min_pq
A priority queue of generic keys.
Definition: min_pq.h:29
min_pq_pop
void * min_pq_pop(t_min_pq *pq)
Removes and returns the smallest key in this queue.
Definition: min_pq_pop.c:38
min_pq_delete
void min_pq_delete(t_min_pq *pq)
Deletes this queue and free all its items and the associated data.
Definition: min_pq_delete.c:16
min_pq_copy
t_min_pq * min_pq_copy(const t_min_pq *pq)
Copies the queue and all it contents.
Definition: min_pq_copy.c:16