C Everything
This is a C repository containing a curated set of generic data structures and algorithm.
queue.c File Reference

Contains definitions of routines supported by queue. More...

#include "queue.h"

Go to the source code of this file.

Functions

void queue_enqueue_ll (t_gen d, t_gen data)
 
add element in queue More...
 
t_gen queue_dequeue_ll (t_gen d)
 
pop front element in queue More...
 
void queue_enqueue_arr (t_gen d, t_gen data)
 
add element in queue More...
 
t_gen queue_dequeue_arr (t_gen d)
 
pop front element in queue More...
 
t_gen queue_peek (t_gen d, int idx)
 
peek front element in queue More...
 
bool queue_full (t_gen d)
 
Check queue full More...
 
bool queue_empty (t_gen d)
 
Check queue empty More...
 
int queue_size (t_gen d)
 
Return queue size More...
 
void queue_print (t_gen d)
 
queue_print_info More...
 
void destroy_queue (t_gen d)
 
Destroy queue instance More...
 
t_gen create_queue (char *name, int max_size, e_queuetype qtype, t_dparams *prm)
 
Destroy queue instance More...
 

Variables

f_ins q_enq [] = {queue_enqueue_ll, queue_enqueue_arr}
 Look Up function ptrs to enq elems to queue. More...
 
f_gen q_deq [] = {queue_dequeue_ll, queue_dequeue_arr}
 Look Up function ptrs to deq elems to queue. More...
 

Detailed Description

Contains definitions of routines supported by queue.

Definition in file queue.c.

Function Documentation

◆ create_queue()

t_gen create_queue ( char *  name,
int  max_size,
e_queuetype  qtype,
t_dparams prm 
)


Destroy queue instance

Parameters
name- Name of queue instance
max_size- Max size of queue instance
type- Type of queue to be created
prm- Data type specific parameters
Returns
- Pointer to instance of queue

Definition at line 37 of file queue.c.

◆ destroy_queue()

void destroy_queue ( t_gen  d)


Destroy queue instance

Parameters
d- Pointer to instance of queue
Returns
- NA

Definition at line 291 of file queue.c.

◆ queue_dequeue_arr()

t_gen queue_dequeue_arr ( t_gen  d)


pop front element in queue

Parameters
d- Pointer to instance of queue
Returns
- Pointer to the data to be poped from

Definition at line 106 of file queue.c.

◆ queue_dequeue_ll()

t_gen queue_dequeue_ll ( t_gen  d)


pop front element in queue

Parameters
d- Pointer to instance of queue
Returns
- Pointer to the data to be popped from

Definition at line 195 of file queue.c.

◆ queue_empty()

bool queue_empty ( t_gen  d)


Check queue empty

Parameters
d- Pointer to instance of queue
Returns
- true if empty

Definition at line 226 of file queue.c.

◆ queue_enqueue_arr()

void queue_enqueue_arr ( t_gen  d,
t_gen  data 
)


add element in queue

Parameters
d- Pointer to instance of queue
data- Pointer to the data to be pushed
Returns
- NA

Definition at line 82 of file queue.c.

◆ queue_enqueue_ll()

void queue_enqueue_ll ( t_gen  d,
t_gen  data 
)


add element in queue

Parameters
d- Pointer to instance of queue
data- Pointer to the data to be pushed
Returns
- NA

Definition at line 175 of file queue.c.

◆ queue_full()

bool queue_full ( t_gen  d)


Check queue full

Parameters
d- Pointer to instance of queue
Returns
- true if full

Definition at line 216 of file queue.c.

◆ queue_peek()

t_gen queue_peek ( t_gen  d,
int  idx 
)


peek front element in queue

Parameters
d- Pointer to instance of queue
idx- Index of data to peek
Returns
- Pointer to the data to data to be peeked

Definition at line 138 of file queue.c.

◆ queue_print()

void queue_print ( t_gen  d)


queue_print_info

Parameters
d- Pointer to instance of queue
Returns
- NA

Definition at line 262 of file queue.c.

◆ queue_size()

int queue_size ( t_gen  d)


Return queue size

Parameters
d- Pointer to instance of queue
Returns
- size of queue

Definition at line 236 of file queue.c.

Variable Documentation

◆ q_deq

Look Up function ptrs to deq elems to queue.

Definition at line 26 of file queue.c.

◆ q_enq

Look Up function ptrs to enq elems to queue.

Definition at line 23 of file queue.c.