\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{DoxyCompactItemize}
\item 
struct \hyperlink{structgqueue__node}{gqueue\+\_\+node}
\item 
struct \hyperlink{structgqueue}{gqueue}
\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \hyperlink{group__adt__gqueue_gab1fc0e8ea556c098adf58484aac34622}{G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+CL}(P\+R\+E\+F\+IX,  T\+Y\+PE)
\item 
\#define \hyperlink{group__adt__gqueue_ga479aaa6063ce1b74c80107e508f295fd}{G\+Q\+U\+E\+U\+E\+\_\+\+P\+U\+S\+H\+\_\+\+D\+E\+FN}(P\+R\+E\+F\+IX,  T\+Y\+PE,  C\+O\+PY)
\item 
\#define \hyperlink{group__adt__gqueue_ga37c8e9aef40bd5d22b303b62a8e6bd2e}{G\+Q\+U\+E\+U\+E\+\_\+\+T\+O\+P\+\_\+\+D\+E\+FN}(P\+R\+E\+F\+IX,  T\+Y\+PE)
\item 
\#define \hyperlink{group__adt__gqueue_gac1cf75461e0f2d3f62fef39b88d9d18a}{G\+Q\+U\+E\+U\+E\+\_\+\+P\+O\+P\+\_\+\+D\+E\+FN}(P\+R\+E\+F\+IX,  F\+R\+EE)
\item 
\#define \hyperlink{group__adt__gqueue_ga8fc5d1d658bcffae05b406d1bdb20988}{G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+FN}(P\+R\+E\+F\+IX,  T\+Y\+PE,  C\+O\+PY,  F\+R\+EE)
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{group__adt__gqueue_gadfc89797b379787018452c54b27dcf47}{gqueue\+\_\+push} (struct \hyperlink{structgqueue}{gqueue} $\ast$d, unsigned datasize, const void $\ast$data, \hyperlink{group__adt_gaa98f7f3499407a5dc1afdcbb20df2e15}{adt\+\_\+copy\+\_\+fn} $\ast$fn)
\item 
void $\ast$ \hyperlink{group__adt__gqueue_ga904529a3ba107ceae877634fa0a09572}{gqueue\+\_\+top} (const struct \hyperlink{structgqueue}{gqueue} $\ast$q)
\item 
void \hyperlink{group__adt__gqueue_gaaac0a9032a341307e9ab54458f1d7d2e}{gqueue\+\_\+pop} (struct \hyperlink{structgqueue}{gqueue} $\ast$q, \hyperlink{group__adt_ga87ba7ca9dce36c22fe75a730a1d768a9}{adt\+\_\+free\+\_\+fn} $\ast$fn)
\end{DoxyCompactItemize}


\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{Macro Definition Documentation}
\mbox{\label{group__adt__gqueue_gab1fc0e8ea556c098adf58484aac34622}} 
\index{adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}!G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+CL@{G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+CL}}
\index{G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+CL@{G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+CL}!adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}}
\subsubsection{\texorpdfstring{G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+CL}{GQUEUE\_DECL}}
{\footnotesize\ttfamily \#define G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+CL(\begin{DoxyParamCaption}\item[{}]{P\+R\+E\+F\+IX,  }\item[{}]{T\+Y\+PE }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keyword}{extern} \textcolor{keywordtype}{int} PREFIX##\_push(\textcolor{keyword}{struct} gqueue* q, TYPE \textcolor{keyword}{const}* data); \(\backslash\)
extern TYPE* PREFIX##\_top(\textcolor{keyword}{struct} gqueue* q); \(\backslash\)
extern \textcolor{keywordtype}{void} PREFIX##\_pop(\textcolor{keyword}{struct} gqueue* q);
\end{DoxyCode}
Declare specialized {\ttfamily gqueue} functions. \begin{Desc}
\item[Examples\+: ]\par
\hyperlink{adt_2gqueue_test_8c-example}{adt/gqueue\+\_\+test.\+c}.\end{Desc}
\mbox{\label{group__adt__gqueue_ga8fc5d1d658bcffae05b406d1bdb20988}} 
\index{adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}!G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+FN@{G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+FN}}
\index{G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+FN@{G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+FN}!adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}}
\subsubsection{\texorpdfstring{G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+FN}{GQUEUE\_DEFN}}
{\footnotesize\ttfamily \#define G\+Q\+U\+E\+U\+E\+\_\+\+D\+E\+FN(\begin{DoxyParamCaption}\item[{}]{P\+R\+E\+F\+IX,  }\item[{}]{T\+Y\+PE,  }\item[{}]{C\+O\+PY,  }\item[{}]{F\+R\+EE }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}
GQUEUE_PUSH_DEFN(PREFIX,TYPE,COPY) \(\backslash\)
GQUEUE\_TOP\_DEFN(PREFIX,TYPE) \(\backslash\)
GQUEUE\_POP\_DEFN(PREFIX,FREE)
\end{DoxyCode}
Define all the specialized {\ttfamily gqueue} functions. If {\ttfamily C\+O\+PY} is {\ttfamily N\+U\+LL}, a simple memcpy is used instead. If {\ttfamily F\+R\+EE} is {\ttfamily N\+U\+LL}, 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}
\mbox{\label{group__adt__gqueue_gac1cf75461e0f2d3f62fef39b88d9d18a}} 
\index{adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}!G\+Q\+U\+E\+U\+E\+\_\+\+P\+O\+P\+\_\+\+D\+E\+FN@{G\+Q\+U\+E\+U\+E\+\_\+\+P\+O\+P\+\_\+\+D\+E\+FN}}
\index{G\+Q\+U\+E\+U\+E\+\_\+\+P\+O\+P\+\_\+\+D\+E\+FN@{G\+Q\+U\+E\+U\+E\+\_\+\+P\+O\+P\+\_\+\+D\+E\+FN}!adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}}
\subsubsection{\texorpdfstring{G\+Q\+U\+E\+U\+E\+\_\+\+P\+O\+P\+\_\+\+D\+E\+FN}{GQUEUE\_POP\_DEFN}}
{\footnotesize\ttfamily \#define G\+Q\+U\+E\+U\+E\+\_\+\+P\+O\+P\+\_\+\+D\+E\+FN(\begin{DoxyParamCaption}\item[{}]{P\+R\+E\+F\+IX,  }\item[{}]{F\+R\+EE }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keywordtype}{void} PREFIX##\_pop(\textcolor{keyword}{struct} gqueue* q) \{ \(\backslash\)
  gqueue\_pop(q, (adt_free_fn*)(FREE)); \(\backslash\)
\}
\end{DoxyCode}
Define a specialized {\ttfamily gqueue} pop function. \mbox{\label{group__adt__gqueue_ga479aaa6063ce1b74c80107e508f295fd}} 
\index{adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}!G\+Q\+U\+E\+U\+E\+\_\+\+P\+U\+S\+H\+\_\+\+D\+E\+FN@{G\+Q\+U\+E\+U\+E\+\_\+\+P\+U\+S\+H\+\_\+\+D\+E\+FN}}
\index{G\+Q\+U\+E\+U\+E\+\_\+\+P\+U\+S\+H\+\_\+\+D\+E\+FN@{G\+Q\+U\+E\+U\+E\+\_\+\+P\+U\+S\+H\+\_\+\+D\+E\+FN}!adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}}
\subsubsection{\texorpdfstring{G\+Q\+U\+E\+U\+E\+\_\+\+P\+U\+S\+H\+\_\+\+D\+E\+FN}{GQUEUE\_PUSH\_DEFN}}
{\footnotesize\ttfamily \#define G\+Q\+U\+E\+U\+E\+\_\+\+P\+U\+S\+H\+\_\+\+D\+E\+FN(\begin{DoxyParamCaption}\item[{}]{P\+R\+E\+F\+IX,  }\item[{}]{T\+Y\+PE,  }\item[{}]{C\+O\+PY }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keywordtype}{int} PREFIX##\_push(\textcolor{keyword}{struct} gqueue* q, TYPE \textcolor{keyword}{const}* data) \{ \(\backslash\)
  return gqueue_push(q, \textcolor{keyword}{sizeof} *data, data, (adt_copy_fn*)COPY); \(\backslash\)
\}
\end{DoxyCode}
Define a specialized {\ttfamily gqueue} push function. \mbox{\label{group__adt__gqueue_ga37c8e9aef40bd5d22b303b62a8e6bd2e}} 
\index{adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}!G\+Q\+U\+E\+U\+E\+\_\+\+T\+O\+P\+\_\+\+D\+E\+FN@{G\+Q\+U\+E\+U\+E\+\_\+\+T\+O\+P\+\_\+\+D\+E\+FN}}
\index{G\+Q\+U\+E\+U\+E\+\_\+\+T\+O\+P\+\_\+\+D\+E\+FN@{G\+Q\+U\+E\+U\+E\+\_\+\+T\+O\+P\+\_\+\+D\+E\+FN}!adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}}
\subsubsection{\texorpdfstring{G\+Q\+U\+E\+U\+E\+\_\+\+T\+O\+P\+\_\+\+D\+E\+FN}{GQUEUE\_TOP\_DEFN}}
{\footnotesize\ttfamily \#define G\+Q\+U\+E\+U\+E\+\_\+\+T\+O\+P\+\_\+\+D\+E\+FN(\begin{DoxyParamCaption}\item[{}]{P\+R\+E\+F\+IX,  }\item[{}]{T\+Y\+PE }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}
TYPE* PREFIX##\_top(\textcolor{keyword}{struct} gqueue* q) \{ \(\backslash\)
  return (q->head == 0) ? 0 : (TYPE*)q->head->data; \(\backslash\)
\}
\end{DoxyCode}
Define a specialized {\ttfamily gqueue} top function. 

\subsection{Function Documentation}
\mbox{\label{group__adt__gqueue_gaaac0a9032a341307e9ab54458f1d7d2e}} 
\index{adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}!gqueue\+\_\+pop@{gqueue\+\_\+pop}}
\index{gqueue\+\_\+pop@{gqueue\+\_\+pop}!adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}}
\subsubsection{\texorpdfstring{gqueue\+\_\+pop()}{gqueue\_pop()}}
{\footnotesize\ttfamily void gqueue\+\_\+pop (\begin{DoxyParamCaption}\item[{struct \hyperlink{structgqueue}{gqueue} $\ast$}]{q,  }\item[{\hyperlink{group__adt_ga87ba7ca9dce36c22fe75a730a1d768a9}{adt\+\_\+free\+\_\+fn} $\ast$}]{fn }\end{DoxyParamCaption})}

Remove the first (least recently pushed) element from the queue. If the free function {\ttfamily fn} is {\ttfamily N\+U\+LL} 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. 

References gqueue\+::count, gqueue\+\_\+node\+::data, gqueue\+::head, gqueue\+\_\+node\+::next, and gqueue\+::tail.

\mbox{\label{group__adt__gqueue_gadfc89797b379787018452c54b27dcf47}} 
\index{adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}!gqueue\+\_\+push@{gqueue\+\_\+push}}
\index{gqueue\+\_\+push@{gqueue\+\_\+push}!adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}}
\subsubsection{\texorpdfstring{gqueue\+\_\+push()}{gqueue\_push()}}
{\footnotesize\ttfamily int gqueue\+\_\+push (\begin{DoxyParamCaption}\item[{struct \hyperlink{structgqueue}{gqueue} $\ast$}]{q,  }\item[{unsigned}]{datasize,  }\item[{const void $\ast$}]{data,  }\item[{\hyperlink{group__adt_gaa98f7f3499407a5dc1afdcbb20df2e15}{adt\+\_\+copy\+\_\+fn} $\ast$}]{fn }\end{DoxyParamCaption})}

Add a new element onto the queue. If the copy function {\ttfamily fn} is {\ttfamily N\+U\+LL} memcpy is used in its place. 

References gqueue\+::count, gqueue\+\_\+node\+::data, gqueue\+::head, gqueue\+\_\+node\+::next, and gqueue\+::tail.

\mbox{\label{group__adt__gqueue_ga904529a3ba107ceae877634fa0a09572}} 
\index{adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}!gqueue\+\_\+top@{gqueue\+\_\+top}}
\index{gqueue\+\_\+top@{gqueue\+\_\+top}!adt gqueue\+: Generic simple queue.@{adt gqueue\+: Generic simple queue.}}
\subsubsection{\texorpdfstring{gqueue\+\_\+top()}{gqueue\_top()}}
{\footnotesize\ttfamily void$\ast$ gqueue\+\_\+top (\begin{DoxyParamCaption}\item[{const struct \hyperlink{structgqueue}{gqueue} $\ast$}]{q }\end{DoxyParamCaption})}

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

References gqueue\+\_\+node\+::data, and gqueue\+::head.

