\section{lib/sparse/\-Binary\-Heap.c File Reference}
\label{BinaryHeap_8c}\index{lib/sparse/\-Binary\-Heap.\-c@{lib/sparse/\-Binary\-Heap.\-c}}
{\ttfamily \#include \char`\"{}Binary\-Heap.\-h\char`\"{}}\\*
Include dependency graph for Binary\-Heap.\-c\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{BinaryHeap_8c__incl}
\end{center}
\end{figure}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define {\bf Parent\-Pos}(pos)~(pos -\/ 1)/2
\item 
\#define {\bf Children\-Pos1}(pos)~(2$\ast$(pos)+1)
\item 
\#define {\bf Children\-Pos2}(pos)~(2$\ast$(pos)+2)
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
{\bf Binary\-Heap} {\bf Binary\-Heap\-\_\-new} ({\bf int}($\ast$cmp)(void $\ast$item1, void $\ast$item2))
\item 
void {\bf Binary\-Heap\-\_\-delete} ({\bf Binary\-Heap} h, void($\ast$del)(void $\ast${\bf item}))
\item 
{\bf int} {\bf Binary\-Heap\-\_\-insert} ({\bf Binary\-Heap} h, void $\ast${\bf item})
\item 
void $\ast$ {\bf Binary\-Heap\-\_\-get\-\_\-min} ({\bf Binary\-Heap} h)
\item 
void $\ast$ {\bf Binary\-Heap\-\_\-extract\-\_\-min} ({\bf Binary\-Heap} h)
\item 
void $\ast$ {\bf Binary\-Heap\-\_\-extract\-\_\-item} ({\bf Binary\-Heap} h, {\bf int} id)
\item 
{\bf int} {\bf Binary\-Heap\-\_\-reset} ({\bf Binary\-Heap} h, {\bf int} id, void $\ast${\bf item})
\item 
void $\ast$ {\bf Binary\-Heap\-\_\-get\-\_\-item} ({\bf Binary\-Heap} h, {\bf int} id)
\item 
void {\bf Binary\-Heap\-\_\-sanity\-\_\-check} ({\bf Binary\-Heap} h)
\item 
void {\bf Binary\-Heap\-\_\-print} ({\bf Binary\-Heap} h, void($\ast$pnt)(void $\ast$))
\end{DoxyCompactItemize}


\subsection{Macro Definition Documentation}
\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Children\-Pos1@{Children\-Pos1}}
\index{Children\-Pos1@{Children\-Pos1}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Children\-Pos1}]{\setlength{\rightskip}{0pt plus 5cm}\#define Children\-Pos1(
\begin{DoxyParamCaption}
\item[{}]{pos}
\end{DoxyParamCaption}
)~(2$\ast$(pos)+1)}\label{BinaryHeap_8c_af018a6fbf7ff9f989d5ab651c5b5c31c}


Definition at line 65 of file Binary\-Heap.\-c.

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Children\-Pos2@{Children\-Pos2}}
\index{Children\-Pos2@{Children\-Pos2}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Children\-Pos2}]{\setlength{\rightskip}{0pt plus 5cm}\#define Children\-Pos2(
\begin{DoxyParamCaption}
\item[{}]{pos}
\end{DoxyParamCaption}
)~(2$\ast$(pos)+2)}\label{BinaryHeap_8c_ab35714cb7e250612262c6a121208cbfc}


Definition at line 66 of file Binary\-Heap.\-c.

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Parent\-Pos@{Parent\-Pos}}
\index{Parent\-Pos@{Parent\-Pos}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Parent\-Pos}]{\setlength{\rightskip}{0pt plus 5cm}\#define Parent\-Pos(
\begin{DoxyParamCaption}
\item[{}]{pos}
\end{DoxyParamCaption}
)~(pos -\/ 1)/2}\label{BinaryHeap_8c_a7af591e3f8c43ed58629d407488ebd30}


Definition at line 64 of file Binary\-Heap.\-c.



Referenced by Binary\-Heap\-\_\-sanity\-\_\-check().



\subsection{Function Documentation}
\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Binary\-Heap\-\_\-delete@{Binary\-Heap\-\_\-delete}}
\index{Binary\-Heap\-\_\-delete@{Binary\-Heap\-\_\-delete}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Binary\-Heap\-\_\-delete}]{\setlength{\rightskip}{0pt plus 5cm}void Binary\-Heap\-\_\-delete (
\begin{DoxyParamCaption}
\item[{{\bf Binary\-Heap}}]{h, }
\item[{void($\ast$)(void $\ast${\bf item})}]{del}
\end{DoxyParamCaption}
)}\label{BinaryHeap_8c_a6fd27466952b94b1b2884abe891047fc}


Definition at line 34 of file Binary\-Heap.\-c.



References F\-R\-E\-E, Binary\-Heap\-\_\-struct\-::heap, Binary\-Heap\-\_\-struct\-::id\-\_\-stack, Binary\-Heap\-\_\-struct\-::id\-\_\-to\-\_\-pos, Int\-Stack\-\_\-delete(), Binary\-Heap\-\_\-struct\-::len, and Binary\-Heap\-\_\-struct\-::pos\-\_\-to\-\_\-id.

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Binary\-Heap\-\_\-extract\-\_\-item@{Binary\-Heap\-\_\-extract\-\_\-item}}
\index{Binary\-Heap\-\_\-extract\-\_\-item@{Binary\-Heap\-\_\-extract\-\_\-item}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Binary\-Heap\-\_\-extract\-\_\-item}]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ Binary\-Heap\-\_\-extract\-\_\-item (
\begin{DoxyParamCaption}
\item[{{\bf Binary\-Heap}}]{h, }
\item[{{\bf int}}]{id}
\end{DoxyParamCaption}
)}\label{BinaryHeap_8c_a3b39c8822c3cd6ed6c35b1f805369177}


Definition at line 175 of file Binary\-Heap.\-c.



References assert, Binary\-Heap\-\_\-struct\-::heap, Binary\-Heap\-\_\-struct\-::id\-\_\-stack, Binary\-Heap\-\_\-struct\-::id\-\_\-to\-\_\-pos, Int\-Stack\-\_\-push(), Binary\-Heap\-\_\-struct\-::len, Binary\-Heap\-\_\-struct\-::max\-\_\-len, and N\-U\-L\-L.



Referenced by Binary\-Heap\-\_\-extract\-\_\-min().

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Binary\-Heap\-\_\-extract\-\_\-min@{Binary\-Heap\-\_\-extract\-\_\-min}}
\index{Binary\-Heap\-\_\-extract\-\_\-min@{Binary\-Heap\-\_\-extract\-\_\-min}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Binary\-Heap\-\_\-extract\-\_\-min}]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ Binary\-Heap\-\_\-extract\-\_\-min (
\begin{DoxyParamCaption}
\item[{{\bf Binary\-Heap}}]{h}
\end{DoxyParamCaption}
)}\label{BinaryHeap_8c_afdc0f98038b09ec5724be501e36e9eb3}


Definition at line 169 of file Binary\-Heap.\-c.



References Binary\-Heap\-\_\-extract\-\_\-item(), Binary\-Heap\-\_\-struct\-::len, N\-U\-L\-L, and Binary\-Heap\-\_\-struct\-::pos\-\_\-to\-\_\-id.

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Binary\-Heap\-\_\-get\-\_\-item@{Binary\-Heap\-\_\-get\-\_\-item}}
\index{Binary\-Heap\-\_\-get\-\_\-item@{Binary\-Heap\-\_\-get\-\_\-item}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Binary\-Heap\-\_\-get\-\_\-item}]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ Binary\-Heap\-\_\-get\-\_\-item (
\begin{DoxyParamCaption}
\item[{{\bf Binary\-Heap}}]{h, }
\item[{{\bf int}}]{id}
\end{DoxyParamCaption}
)}\label{BinaryHeap_8c_a96955c59ab1dc25822b7aa4790c3a9d2}


Definition at line 225 of file Binary\-Heap.\-c.



References Binary\-Heap\-\_\-struct\-::heap, Binary\-Heap\-\_\-struct\-::id\-\_\-to\-\_\-pos, Binary\-Heap\-\_\-struct\-::max\-\_\-len, and N\-U\-L\-L.

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Binary\-Heap\-\_\-get\-\_\-min@{Binary\-Heap\-\_\-get\-\_\-min}}
\index{Binary\-Heap\-\_\-get\-\_\-min@{Binary\-Heap\-\_\-get\-\_\-min}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Binary\-Heap\-\_\-get\-\_\-min}]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ Binary\-Heap\-\_\-get\-\_\-min (
\begin{DoxyParamCaption}
\item[{{\bf Binary\-Heap}}]{h}
\end{DoxyParamCaption}
)}\label{BinaryHeap_8c_af0c6cc3683bab332d35f3a6c44e32443}


Definition at line 164 of file Binary\-Heap.\-c.



References Binary\-Heap\-\_\-struct\-::heap.

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Binary\-Heap\-\_\-insert@{Binary\-Heap\-\_\-insert}}
\index{Binary\-Heap\-\_\-insert@{Binary\-Heap\-\_\-insert}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Binary\-Heap\-\_\-insert}]{\setlength{\rightskip}{0pt plus 5cm}{\bf int} Binary\-Heap\-\_\-insert (
\begin{DoxyParamCaption}
\item[{{\bf Binary\-Heap}}]{h, }
\item[{void $\ast$}]{item}
\end{DoxyParamCaption}
)}\label{BinaryHeap_8c_aa4f1e62e8254012fb857124399f74660}


Definition at line 137 of file Binary\-Heap.\-c.



References assert, Binary\-Heap\-\_\-error\-\_\-malloc, Binary\-Heap\-\_\-struct\-::heap, Binary\-Heap\-\_\-struct\-::id\-\_\-stack, Binary\-Heap\-\_\-struct\-::id\-\_\-to\-\_\-pos, Int\-Stack\-\_\-pop(), Binary\-Heap\-\_\-struct\-::len, Binary\-Heap\-\_\-struct\-::max\-\_\-len, N\-U\-L\-L, and Binary\-Heap\-\_\-struct\-::pos\-\_\-to\-\_\-id.

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Binary\-Heap\-\_\-new@{Binary\-Heap\-\_\-new}}
\index{Binary\-Heap\-\_\-new@{Binary\-Heap\-\_\-new}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Binary\-Heap\-\_\-new}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Binary\-Heap} Binary\-Heap\-\_\-new (
\begin{DoxyParamCaption}
\item[{{\bf int}($\ast$)(void $\ast$item1, void $\ast$item2)}]{cmp}
\end{DoxyParamCaption}
)}\label{BinaryHeap_8c_a54d05122a9a52ccc8b81a25c84fa09b4}


Definition at line 16 of file Binary\-Heap.\-c.



References Binary\-Heap\-\_\-struct\-::cmp, Binary\-Heap\-\_\-struct\-::heap, Binary\-Heap\-\_\-struct\-::id\-\_\-stack, Binary\-Heap\-\_\-struct\-::id\-\_\-to\-\_\-pos, Int\-Stack\-\_\-new(), Binary\-Heap\-\_\-struct\-::len, M\-A\-L\-L\-O\-C, Binary\-Heap\-\_\-struct\-::max\-\_\-len, and Binary\-Heap\-\_\-struct\-::pos\-\_\-to\-\_\-id.

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Binary\-Heap\-\_\-print@{Binary\-Heap\-\_\-print}}
\index{Binary\-Heap\-\_\-print@{Binary\-Heap\-\_\-print}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Binary\-Heap\-\_\-print}]{\setlength{\rightskip}{0pt plus 5cm}void Binary\-Heap\-\_\-print (
\begin{DoxyParamCaption}
\item[{{\bf Binary\-Heap}}]{h, }
\item[{void($\ast$)(void $\ast$)}]{pnt}
\end{DoxyParamCaption}
)}\label{BinaryHeap_8c_a002ae90689d22a37ddba81b7c350bfc6}


Definition at line 273 of file Binary\-Heap.\-c.



References Binary\-Heap\-\_\-struct\-::heap, Binary\-Heap\-\_\-struct\-::id\-\_\-stack, Binary\-Heap\-\_\-struct\-::id\-\_\-to\-\_\-pos, Int\-Stack\-\_\-struct\-::last, Binary\-Heap\-\_\-struct\-::len, Binary\-Heap\-\_\-struct\-::pos\-\_\-to\-\_\-id, and Int\-Stack\-\_\-struct\-::stack.

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Binary\-Heap\-\_\-reset@{Binary\-Heap\-\_\-reset}}
\index{Binary\-Heap\-\_\-reset@{Binary\-Heap\-\_\-reset}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Binary\-Heap\-\_\-reset}]{\setlength{\rightskip}{0pt plus 5cm}{\bf int} Binary\-Heap\-\_\-reset (
\begin{DoxyParamCaption}
\item[{{\bf Binary\-Heap}}]{h, }
\item[{{\bf int}}]{id, }
\item[{void $\ast$}]{item}
\end{DoxyParamCaption}
)}\label{BinaryHeap_8c_aa87dcc11b5d4d2f36d34ca48f275e034}


Definition at line 208 of file Binary\-Heap.\-c.



References Binary\-Heap\-\_\-struct\-::heap, Binary\-Heap\-\_\-struct\-::id\-\_\-to\-\_\-pos, and Binary\-Heap\-\_\-struct\-::max\-\_\-len.

\index{Binary\-Heap.\-c@{Binary\-Heap.\-c}!Binary\-Heap\-\_\-sanity\-\_\-check@{Binary\-Heap\-\_\-sanity\-\_\-check}}
\index{Binary\-Heap\-\_\-sanity\-\_\-check@{Binary\-Heap\-\_\-sanity\-\_\-check}!BinaryHeap.c@{Binary\-Heap.\-c}}
\subsubsection[{Binary\-Heap\-\_\-sanity\-\_\-check}]{\setlength{\rightskip}{0pt plus 5cm}void Binary\-Heap\-\_\-sanity\-\_\-check (
\begin{DoxyParamCaption}
\item[{{\bf Binary\-Heap}}]{h}
\end{DoxyParamCaption}
)}\label{BinaryHeap_8c_a87ed81848857b8052f565b0e5e71f185}


Definition at line 237 of file Binary\-Heap.\-c.



References assert, Binary\-Heap\-\_\-struct\-::cmp, F\-R\-E\-E, Binary\-Heap\-\_\-struct\-::heap, Binary\-Heap\-\_\-struct\-::id\-\_\-stack, Binary\-Heap\-\_\-struct\-::id\-\_\-to\-\_\-pos, Int\-Stack\-\_\-get\-\_\-length, Int\-Stack\-\_\-struct\-::last, Binary\-Heap\-\_\-struct\-::len, M\-A\-L\-L\-O\-C, Parent\-Pos, Binary\-Heap\-\_\-struct\-::pos\-\_\-to\-\_\-id, and Int\-Stack\-\_\-struct\-::stack.

