\hypertarget{group__adt__gqueue}{
\section{adt gqueue: Generic simple queue.}
\label{group__adt__gqueue}\index{adt gqueue: Generic simple queue.@{adt gqueue: Generic simple queue.}}
}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{structgqueue__node}{gqueue\_\-node}
\item 
struct \hyperlink{structgqueue}{gqueue}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define \hyperlink{group__adt__gqueue_gb1fc0e8ea556c098adf58484aac34622}{GQUEUE\_\-DECL}(PREFIX, TYPE)
\item 
\#define \hyperlink{group__adt__gqueue_g479aaa6063ce1b74c80107e508f295fd}{GQUEUE\_\-PUSH\_\-DEFN}(PREFIX, TYPE, COPY)
\item 
\#define \hyperlink{group__adt__gqueue_g37c8e9aef40bd5d22b303b62a8e6bd2e}{GQUEUE\_\-TOP\_\-DEFN}(PREFIX, TYPE)
\item 
\#define \hyperlink{group__adt__gqueue_gc1cf75461e0f2d3f62fef39b88d9d18a}{GQUEUE\_\-POP\_\-DEFN}(PREFIX, FREE)
\item 
\#define \hyperlink{group__adt__gqueue_g8fc5d1d658bcffae05b406d1bdb20988}{GQUEUE\_\-DEFN}(PREFIX, TYPE, COPY, FREE)
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{group__adt__gqueue_gdfc89797b379787018452c54b27dcf47}{gqueue\_\-push} (struct \hyperlink{structgqueue}{gqueue} $\ast$d, unsigned datasize, const void $\ast$data, \hyperlink{group__adt_ga98f7f3499407a5dc1afdcbb20df2e15}{adt\_\-copy\_\-fn} $\ast$fn)
\item 
void $\ast$ \hyperlink{group__adt__gqueue_g904529a3ba107ceae877634fa0a09572}{gqueue\_\-top} (const struct \hyperlink{structgqueue}{gqueue} $\ast$q)
\item 
void \hyperlink{group__adt__gqueue_gaac0a9032a341307e9ab54458f1d7d2e}{gqueue\_\-pop} (struct \hyperlink{structgqueue}{gqueue} $\ast$q, \hyperlink{group__adt_g87ba7ca9dce36c22fe75a730a1d768a9}{adt\_\-free\_\-fn} $\ast$fn)
\end{CompactItemize}


\subsection{Detailed Description}
A generic queue is a first-in-first-out structure defined here based on three primary operations: push, top, and pop. Pushing an element onto a queue adds it to the tail of the list. The top operation fetches the least recently pushed element still on the queue, and popping removes it. 

\subsection{Define Documentation}
\hypertarget{group__adt__gqueue_gb1fc0e8ea556c098adf58484aac34622}{
\index{adt_gqueue@{adt\_\-gqueue}!GQUEUE_DECL@{GQUEUE\_\-DECL}}
\index{GQUEUE_DECL@{GQUEUE\_\-DECL}!adt_gqueue@{adt\_\-gqueue}}
\subsubsection[GQUEUE\_\-DECL]{\setlength{\rightskip}{0pt plus 5cm}\#define GQUEUE\_\-DECL(PREFIX, TYPE)}}
\label{group__adt__gqueue_gb1fc0e8ea556c098adf58484aac34622}


\textbf{Value:}

\begin{Code}\begin{verbatim}extern int PREFIX##_push(struct gqueue* q, TYPE const* data); \
extern TYPE* PREFIX##_top(struct gqueue* q); \
extern void PREFIX##_pop(struct gqueue* q);
\end{verbatim}\end{Code}
Declare specialized {\tt gqueue} functions. \begin{Desc}
\item[Examples: ]\par
\hyperlink{adt_2gqueue__test_8c-example}{adt/gqueue\_\-test.c}.\end{Desc}
\hypertarget{group__adt__gqueue_g8fc5d1d658bcffae05b406d1bdb20988}{
\index{adt_gqueue@{adt\_\-gqueue}!GQUEUE_DEFN@{GQUEUE\_\-DEFN}}
\index{GQUEUE_DEFN@{GQUEUE\_\-DEFN}!adt_gqueue@{adt\_\-gqueue}}
\subsubsection[GQUEUE\_\-DEFN]{\setlength{\rightskip}{0pt plus 5cm}\#define GQUEUE\_\-DEFN(PREFIX, TYPE, COPY, FREE)}}
\label{group__adt__gqueue_g8fc5d1d658bcffae05b406d1bdb20988}


\textbf{Value:}

\begin{Code}\begin{verbatim}GQUEUE_PUSH_DEFN(PREFIX,TYPE,COPY) \
GQUEUE_TOP_DEFN(PREFIX,TYPE) \
GQUEUE_POP_DEFN(PREFIX,FREE)
\end{verbatim}\end{Code}
Define all the specialized {\tt gqueue} functions. If {\tt COPY} is {\tt NULL}, a simple memcpy is used instead. If {\tt FREE} is {\tt NULL}, no attempt is made to free the data. \begin{Desc}
\item[Examples: ]\par
\hyperlink{adt_2gqueue__test_8c-example}{adt/gqueue\_\-test.c}.\end{Desc}
\hypertarget{group__adt__gqueue_gc1cf75461e0f2d3f62fef39b88d9d18a}{
\index{adt_gqueue@{adt\_\-gqueue}!GQUEUE_POP_DEFN@{GQUEUE\_\-POP\_\-DEFN}}
\index{GQUEUE_POP_DEFN@{GQUEUE\_\-POP\_\-DEFN}!adt_gqueue@{adt\_\-gqueue}}
\subsubsection[GQUEUE\_\-POP\_\-DEFN]{\setlength{\rightskip}{0pt plus 5cm}\#define GQUEUE\_\-POP\_\-DEFN(PREFIX, FREE)}}
\label{group__adt__gqueue_gc1cf75461e0f2d3f62fef39b88d9d18a}


\textbf{Value:}

\begin{Code}\begin{verbatim}void PREFIX##_pop(struct gqueue* q) { \
  gqueue_pop(q, (adt_free_fn*)(FREE)); \
}
\end{verbatim}\end{Code}
Define a specialized {\tt gqueue} pop function. \hypertarget{group__adt__gqueue_g479aaa6063ce1b74c80107e508f295fd}{
\index{adt_gqueue@{adt\_\-gqueue}!GQUEUE_PUSH_DEFN@{GQUEUE\_\-PUSH\_\-DEFN}}
\index{GQUEUE_PUSH_DEFN@{GQUEUE\_\-PUSH\_\-DEFN}!adt_gqueue@{adt\_\-gqueue}}
\subsubsection[GQUEUE\_\-PUSH\_\-DEFN]{\setlength{\rightskip}{0pt plus 5cm}\#define GQUEUE\_\-PUSH\_\-DEFN(PREFIX, TYPE, COPY)}}
\label{group__adt__gqueue_g479aaa6063ce1b74c80107e508f295fd}


\textbf{Value:}

\begin{Code}\begin{verbatim}int PREFIX##_push(struct gqueue* q, TYPE const* data) { \
  return gqueue_push(q, sizeof *data, data, (adt_copy_fn*)COPY); \
}
\end{verbatim}\end{Code}
Define a specialized {\tt gqueue} push function. \hypertarget{group__adt__gqueue_g37c8e9aef40bd5d22b303b62a8e6bd2e}{
\index{adt_gqueue@{adt\_\-gqueue}!GQUEUE_TOP_DEFN@{GQUEUE\_\-TOP\_\-DEFN}}
\index{GQUEUE_TOP_DEFN@{GQUEUE\_\-TOP\_\-DEFN}!adt_gqueue@{adt\_\-gqueue}}
\subsubsection[GQUEUE\_\-TOP\_\-DEFN]{\setlength{\rightskip}{0pt plus 5cm}\#define GQUEUE\_\-TOP\_\-DEFN(PREFIX, TYPE)}}
\label{group__adt__gqueue_g37c8e9aef40bd5d22b303b62a8e6bd2e}


\textbf{Value:}

\begin{Code}\begin{verbatim}TYPE* PREFIX##_top(struct gqueue* q) { \
  return (q->head == 0) ? 0 : (TYPE*)q->head->data; \
}
\end{verbatim}\end{Code}
Define a specialized {\tt gqueue} top function. 

\subsection{Function Documentation}
\hypertarget{group__adt__gqueue_gaac0a9032a341307e9ab54458f1d7d2e}{
\index{adt_gqueue@{adt\_\-gqueue}!gqueue_pop@{gqueue\_\-pop}}
\index{gqueue_pop@{gqueue\_\-pop}!adt_gqueue@{adt\_\-gqueue}}
\subsubsection[gqueue\_\-pop]{\setlength{\rightskip}{0pt plus 5cm}void gqueue\_\-pop (struct \hyperlink{structgqueue}{gqueue} $\ast$ {\em q}, \hyperlink{group__adt_g87ba7ca9dce36c22fe75a730a1d768a9}{adt\_\-free\_\-fn} $\ast$ {\em fn})}}
\label{group__adt__gqueue_gaac0a9032a341307e9ab54458f1d7d2e}


Remove the first (least recently pushed) element from the queue. If the free function {\tt fn} is {\tt NULL} no data freeing is done. Note that this does not return a pointer to the popped item, as once the item has been popped it is also freed. \hypertarget{group__adt__gqueue_gdfc89797b379787018452c54b27dcf47}{
\index{adt_gqueue@{adt\_\-gqueue}!gqueue_push@{gqueue\_\-push}}
\index{gqueue_push@{gqueue\_\-push}!adt_gqueue@{adt\_\-gqueue}}
\subsubsection[gqueue\_\-push]{\setlength{\rightskip}{0pt plus 5cm}int gqueue\_\-push (struct \hyperlink{structgqueue}{gqueue} $\ast$ {\em q}, unsigned {\em datasize}, const void $\ast$ {\em data}, \hyperlink{group__adt_ga98f7f3499407a5dc1afdcbb20df2e15}{adt\_\-copy\_\-fn} $\ast$ {\em fn})}}
\label{group__adt__gqueue_gdfc89797b379787018452c54b27dcf47}


Add a new element onto the queue. If the copy function {\tt fn} is {\tt NULL} memcpy is used in its place. \hypertarget{group__adt__gqueue_g904529a3ba107ceae877634fa0a09572}{
\index{adt_gqueue@{adt\_\-gqueue}!gqueue_top@{gqueue\_\-top}}
\index{gqueue_top@{gqueue\_\-top}!adt_gqueue@{adt\_\-gqueue}}
\subsubsection[gqueue\_\-top]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ gqueue\_\-top (const struct \hyperlink{structgqueue}{gqueue} $\ast$ {\em q})}}
\label{group__adt__gqueue_g904529a3ba107ceae877634fa0a09572}


Return the address of first (least recently pushed) element in the queue. 