Mescal
Loading...
Searching...
No Matches
type_binheap.h
Go to the documentation of this file.
1
6#ifndef BINHEAP_H_
7#define BINHEAP_H_
8
9 /* ____ _ _ _ */
10 /* | __ )(_)_ __ __ _ _ __ _ _ | | | | ___ __ _ _ __ ___ */
11 /* | _ \| | '_ \ / _` | '__| | | | | |_| |/ _ \/ _` | '_ \/ __| */
12 /* | |_) | | | | | (_| | | | |_| | | _ | __/ (_| | |_) \__ \ */
13 /* |____/|_|_| |_|\__,_|_| \__, | |_| |_|\___|\__,_| .__/|___/ */
14 /* |___/ |_| */
15
16#include <stdio.h>
17#include <stdbool.h>
18#include "alloc.h"
19#include "type_basic.h"
20
21
26typedef struct {
27 void** array;
29 uint size_heap;
30 int (*fc)(void*, void*);
31} binheap;
32
33/***********************/
34/* Auxiliary functions */
35/***********************/
36
44int fcmp_int(void* x, void* y);
45
53int fcmp_uint(void* x, void* y);
54
55
56/************************/
57/* Fonctions primitives */
58/************************/
59
67binheap* create_binheap(int (*) (void*, void*)
68);
69
78);
79
88);
89
98);
99
104void push_binheap(binheap*,
105 void*
106);
107
116);
117
126);
127
128#endif
Macros and functions to help memory allocation.
Type used to represent a binary heap.
Definition type_binheap.h:26
void ** array
Array which stores all values inside the heap.
Definition type_binheap.h:27
uint size_array
Size of the array.
Definition type_binheap.h:28
uint size_heap
Size of the heap (number of values which are currently stored).
Definition type_binheap.h:29
int(* fc)(void *, void *)
Comparison function utilized by the heap.
Definition type_binheap.h:30
Basic types.
void push_binheap(binheap *, void *)
Inserts a new value inside a binary heap.
Definition type_binheap.c:105
int fcmp_int(void *x, void *y)
Comparison function for integers.
Definition type_binheap.c:8
void delete_binheap(binheap *)
Release of a binary heap.
Definition type_binheap.c:73
int fcmp_uint(void *x, void *y)
Comparison function for usigned integers.
Definition type_binheap.c:12
int getsize_binheap(binheap *)
Computes the size of of a binary heap.
Definition type_binheap.c:85
void * peekmin_binheap(binheap *)
Computes the minimum value of a binary heap without removing it.
Definition type_binheap.c:116
void * popmin_binheap(binheap *)
Computes the minimum value of a binary heap and removes it.
Definition type_binheap.c:143
binheap * create_binheap(int(*)(void *, void *))
Creation of an empty binary heap.
Definition type_binheap.c:62
bool isempty_binheap(binheap *)
Tests if a binary heap is empty.
Definition type_binheap.c:80