C Everything
This is a C repository containing a curated set of generic data structures and algorithm.
heap.h
Go to the documentation of this file.
1 
5 #pragma once
6 #include "common.h"
7 
9 typedef enum {
12 } e_heaptype;
13 
15 typedef t_gen (*f_update)(t_gen d, t_gen val, int idx);
16 
18 typedef struct heap {
19  // heap info params
20  char *name;
21  int count;
22  int size;
24  // data on which heap operates
26 
27  // heap roputines
38 
39  // routies for operating on data
47 
48 // Heap interface API
49 t_gen create_heap(char *name, t_gen data,int size, e_heaptype htype, t_dparams *prm);
Top level include containg common headers.
t_gen(* f_update)(t_gen d, t_gen val, int idx)
heapf update key fn defn
Definition: heap.h:15
struct heap t_heap
Heap struct defn.
e_heaptype
Types of heaps.
Definition: heap.h:9
@ eMIN_HEAP
Minimum Heap
Definition: heap.h:10
@ eMAX_HEAP
Maximum Heap.
Definition: heap.h:11
t_gen create_heap(char *name, t_gen data, int size, e_heaptype htype, t_dparams *prm)
Create an instance of heap
Definition: heap.c:29
data params struct defn
Definition: common.h:18
Heap struct defn.
Definition: heap.h:18
f_update update
routine to update a key of given heap node
Definition: heap.h:32
f_len len
routine to get heap len
Definition: heap.h:33
f_cmpr cmpr
Definition: heap.h:40
f_ins insert
routine to insert elements in heap
Definition: heap.h:28
f_get_idx get_idx
Definition: heap.h:44
f_vgen sort
routine to heap sort
Definition: heap.h:31
f_print print
routine to print heap info
Definition: heap.h:36
int size
Max Size of heap.
Definition: heap.h:22
char * name
Stack instance name.
Definition: heap.h:20
f_vgen build
routine to heapify
Definition: heap.h:30
f_destroy destroy
routine to destroy
Definition: heap.h:37
f_empty empty
routine to check if heap empty
Definition: heap.h:35
f_swp_idx swap_idx
Definition: heap.h:43
f_cpy_idx copy_idx
Definition: heap.h:42
f_print print_data
Definition: heap.h:45
f_full full
routine to check if heap full
Definition: heap.h:34
e_heaptype type
Stack Type.
Definition: heap.h:23
int count
Total elems present in heap.
Definition: heap.h:21
f_gen extract
routine to extract min/max root element in heap
Definition: heap.h:29
t_gen * data
Ptr to array based heap.
Definition: heap.h:25
f_cmp_idx cmpr_idx
Definition: heap.h:41
void(* f_vgen)(t_gen)
fn ptr that takes one gen ptr and return nothing
Definition: typedefs.h:49
bool(* f_empty)(t_gen)
fn type of an empty function
Definition: typedefs.h:53
f_vgen f_print
fn type to print function
Definition: typedefs.h:56
f_vgen f_destroy
fn type of destroy function
Definition: typedefs.h:61
void(* f_cpy_idx)(t_gen, int, t_gen)
Definition: typedefs.h:73
e_cmpr(* f_cmpr)(t_gen, t_gen)
Basic operations required for generic data type support.
Definition: typedefs.h:66
f_genidx f_get_idx
fn type of delete elem at idx function
Definition: typedefs.h:63
void(* f_swp_idx)(t_gen, int, int)
Definition: typedefs.h:72
bool(* f_full)(t_gen)
fn type of a full function
Definition: typedefs.h:54
int(* f_len)(t_gen)
fn type of get len function
Definition: typedefs.h:55
void * t_gen
Base Data type used for all data structure and data elements.
Definition: typedefs.h:41
f_vgen2 f_ins
fn type of insert elem function
Definition: typedefs.h:58
t_gen(* f_gen)(t_gen)
Generic data pointer definitions that are common to most data structure operations.
Definition: typedefs.h:46
e_cmpr(* f_cmp_idx)(t_gen, int, int)
Definition: typedefs.h:71