C Everything
This is a C repository containing a curated set of generic data structures and algorithm.
stack.h
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include "common.h"
8 #include "link_list.h"
9 
10 
12 typedef enum {
16 } e_stacktype;
17 
19 typedef struct stack {
20  // stack count, size and top refr
21  char *name;
22  int count;
23  int max_size;
24  int top;
26  // link List or array based stack
37 
42 
43 // API
44 t_gen create_stack (char *name, int max_size, e_stacktype, t_dparams*);
Top level include containg common headers.
struct stack t_stack
stack struct defn
t_gen create_stack(char *name, int max_size, e_stacktype, t_dparams *)
Create an instance of stack
Definition: stack.c:37
e_stacktype
types of supported stacks
Definition: stack.h:12
@ eARRAY_STACK
Top Growing Stack.
Definition: stack.h:14
@ eLL_STACK
LinkList based Stack.
Definition: stack.h:13
@ eARRAY_STACK_DOWN
Down Growing Stack.
Definition: stack.h:15
data params struct defn
Definition: common.h:18
stack struct defn
Definition: stack.h:19
f_len len
routine to get len of stack
Definition: stack.h:34
f_vgen destroy
routine to destroy stack contents
Definition: stack.h:36
f_print print
routine to print stack contents
Definition: stack.h:35
f_gen2 push
stack operations
Definition: stack.h:29
char * name
Stack instance name.
Definition: stack.h:21
f_empty empty
routine to check if stack is empty
Definition: stack.h:33
f_free free
routies for operating on data
Definition: stack.h:39
f_genidx peek
routine to peek elements in stack
Definition: stack.h:31
int max_size
Max Size of stack.
Definition: stack.h:23
f_print print_data
Definition: stack.h:40
f_full full
routine to check if stack is full
Definition: stack.h:32
e_stacktype type
Stack Type.
Definition: stack.h:25
int count
Total elems present in stack.
Definition: stack.h:22
f_gen pop
routine to pop element into stack
Definition: stack.h:30
t_gen * data
Definition: stack.h:27
int top
Stack Top.
Definition: stack.h:24
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
void(* f_free)(t_gen, char *, int)
Definition: typedefs.h:67
f_vgen f_print
fn type to print function
Definition: typedefs.h:56
t_gen(* f_genidx)(t_gen, int)
fn ptr that takes one gen ptr, idx and return gen ptr
Definition: typedefs.h:51
bool(* f_full)(t_gen)
fn type of a full function
Definition: typedefs.h:54
t_gen(* f_gen2)(t_gen, t_gen)
fn ptr that takes two gen ptr and return gen ptr
Definition: typedefs.h:47
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
t_gen(* f_gen)(t_gen)
Generic data pointer definitions that are common to most data structure operations.
Definition: typedefs.h:46