data_structures
max_pq.h
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* max_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:18:46 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #ifndef MAX_PQ_H
15 
16 # define MAX_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_max_pq;
30 
39 t_max_pq *max_pq_new(const t_type *type);
40 
46 void *max_pq_peek(const t_max_pq *pq);
47 
53 void *max_pq_pop(t_max_pq *pq);
54 
60 void max_pq_add(t_max_pq *pq, const void *data);
61 
67 size_t max_pq_size(const t_max_pq *pq);
68 
73 void max_pq_delete(t_max_pq *pq);
74 
80 t_max_pq *max_pq_copy(const t_max_pq *pq);
81 
82 #endif
max_pq_size
size_t max_pq_size(const t_max_pq *pq)
Returns the number of keys in this queue.
Definition: max_pq_size.c:16
max_pq_delete
void max_pq_delete(t_max_pq *pq)
Deletes this queue and free all its items and the associated data.
Definition: max_pq_delete.c:16
types.h
max_pq_new
t_max_pq * max_pq_new(const t_type *type)
Initializes a new empty priority queue.
Definition: max_pq_new.c:16
max_pq_add
void max_pq_add(t_max_pq *pq, const void *data)
Adds a copy of the specified element to the queue.
Definition: max_pq_add.c:30
max_pq_pop
void * max_pq_pop(t_max_pq *pq)
Removes and returns the largest key in this queue.
Definition: max_pq_pop.c:38
array.h
utils.h
max_pq_peek
void * max_pq_peek(const t_max_pq *pq)
Returns the largest key in the queue.
Definition: max_pq_peek.c:16
max_pq_copy
t_max_pq * max_pq_copy(const t_max_pq *pq)
Copies the queue and all it contents.
Definition: max_pq_copy.c:16
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_max_pq
t_array t_max_pq
A priority queue of generic keys.
Definition: max_pq.h:29