Mescal
Loading...
Searching...
No Matches
type_binheap.h File Reference

Implementation of generic binary heaps. More...

#include <stdio.h>
#include <stdbool.h>
#include "alloc.h"
#include "type_basic.h"

Go to the source code of this file.

Classes

struct  binheap
 Type used to represent a binary heap. More...
 

Functions

int fcmp_int (void *x, void *y)
 Comparison function for integers.
 
int fcmp_uint (void *x, void *y)
 Comparison function for usigned integers.
 
binheapcreate_binheap (int(*)(void *, void *))
 Creation of an empty binary heap.
 
void delete_binheap (binheap *)
 Release of a binary heap.
 
bool isempty_binheap (binheap *)
 Tests if a binary heap is empty.
 
int getsize_binheap (binheap *)
 Computes the size of of a binary heap.
 
void push_binheap (binheap *, void *)
 Inserts a new value inside a binary heap.
 
void * peekmin_binheap (binheap *)
 Computes the minimum value of a binary heap without removing it.
 
void * popmin_binheap (binheap *)
 Computes the minimum value of a binary heap and removes it.
 

Detailed Description

Implementation of generic binary heaps.

Function Documentation

◆ create_binheap()

binheap * create_binheap ( int(* fc )(void *, void *))

Creation of an empty binary heap.

Returns
The binary heap.
Parameters
fcThe comparison function.

◆ delete_binheap()

void delete_binheap ( binheap * p)

Release of a binary heap.

Attention
The values inside the heap are not released themselves.
Parameters
pThe binary heap.

◆ fcmp_int()

int fcmp_int ( void * x,
void * y )

Comparison function for integers.

Returns
The comparison

◆ fcmp_uint()

int fcmp_uint ( void * x,
void * y )

Comparison function for usigned integers.

Returns
The comparison.

◆ getsize_binheap()

int getsize_binheap ( binheap * p)

Computes the size of of a binary heap.

Returns
The size of the binary heap.
Parameters
pThe binary heap.

◆ isempty_binheap()

bool isempty_binheap ( binheap * p)

Tests if a binary heap is empty.

Returns
A Boolean indicating if the binary heap is empty.
Parameters
pThe binary heap.

◆ peekmin_binheap()

void * peekmin_binheap ( binheap * p)

Computes the minimum value of a binary heap without removing it.

Returns
The minimum value.
Parameters
pThe binary heap.

◆ popmin_binheap()

void * popmin_binheap ( binheap * p)

Computes the minimum value of a binary heap and removes it.

Returns
The minimum value.
Parameters
pThe binary heap.

◆ push_binheap()

void push_binheap ( binheap * p,
void * val )

Inserts a new value inside a binary heap.

Parameters
pThe binary heap.
valThe value.