\hypertarget{group__vheap}{\section{Vheap}
\label{group__vheap}\index{Vheap@{Vheap}}
}


The Vheap structure.  


Collaboration diagram for Vheap\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=287pt]{group__vheap}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
Vheap $\ast$ \hyperlink{group__vheap_gaa57ffd6ed456de1b80d08a9c0cd0dc38}{elektra\+Vheap\+Init} (Vheap\+Comp comp, size\+\_\+t min\+Size)
\begin{DoxyCompactList}\small\item\em Allocates vheap with size specified by parameter min\+Size. \end{DoxyCompactList}\item 
int \hyperlink{group__vheap_gac300479bc8306d462346e9d27ad67d0f}{elektra\+Vheap\+Is\+Empty} (const Vheap $\ast$vheap)
\begin{DoxyCompactList}\small\item\em Checks if the heap is empty. \end{DoxyCompactList}\item 
\hypertarget{group__vheap_gad26b7fd706901a5c3a3f172f7147e711}{void \hyperlink{group__vheap_gad26b7fd706901a5c3a3f172f7147e711}{elektra\+Vheap\+Del} (Vheap $\ast$vheap)}\label{group__vheap_gad26b7fd706901a5c3a3f172f7147e711}

\begin{DoxyCompactList}\small\item\em Deletes the heap, by freeing all the memory. \end{DoxyCompactList}\item 
int \hyperlink{group__vheap_ga038490c3f8458b51c916d1d8bb496e86}{elektra\+Vheap\+Insert} (Vheap $\ast$vheap, void $\ast$data)
\begin{DoxyCompactList}\small\item\em Inserts an element in the Vheap, by finding the right position. \end{DoxyCompactList}\item 
void $\ast$ \hyperlink{group__vheap_gad2f5b57d9f3acef8c7679eb1795ca436}{elektra\+Vheap\+Remove} (Vheap $\ast$vheap)
\begin{DoxyCompactList}\small\item\em Removes and returns an element from the Vheap, by taking the first element which is ordered by Vheap\+Comp, after removal the remaining elements get ordered again. \end{DoxyCompactList}\item 
int \hyperlink{group__vheap_ga972b02276df378c46d8966726c2b337c}{elektra\+Vheap\+Clear} (Vheap $\ast$vheap)
\begin{DoxyCompactList}\small\item\em Clears the heap in a fast fashion. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
The Vheap structure. 

A heap is a Data structure which keeps the data ordered. Elements can only be retrieved in this order! Insertions and retrieves need log (n).

This implementation allocates memory dynamically. The space gets doubled if full and reduced by half if used only a quarter of it, but not less than min\+Size.

To construct a max heap the comparison function Vheap\+Comp (a, b), must return 1 on a $>$ b and 0 otherwise. For a min heap 1 on a $<$ b and 0 otherwise. 

\subsection{Function Documentation}
\hypertarget{group__vheap_ga972b02276df378c46d8966726c2b337c}{\index{Vheap@{Vheap}!elektra\+Vheap\+Clear@{elektra\+Vheap\+Clear}}
\index{elektra\+Vheap\+Clear@{elektra\+Vheap\+Clear}!Vheap@{Vheap}}
\subsubsection[{elektra\+Vheap\+Clear}]{\setlength{\rightskip}{0pt plus 5cm}int elektra\+Vheap\+Clear (
\begin{DoxyParamCaption}
\item[{Vheap $\ast$}]{vheap}
\end{DoxyParamCaption}
)}}\label{group__vheap_ga972b02276df378c46d8966726c2b337c}


Clears the heap in a fast fashion. 

Set the count to zero and does not reallocate memory. The next reallocation happens at Remove.


\begin{DoxyRetVals}{Return values}
{\em 1} & on success \\
\hline
{\em 0} & on error \\
\hline
\end{DoxyRetVals}
\hypertarget{group__vheap_gaa57ffd6ed456de1b80d08a9c0cd0dc38}{\index{Vheap@{Vheap}!elektra\+Vheap\+Init@{elektra\+Vheap\+Init}}
\index{elektra\+Vheap\+Init@{elektra\+Vheap\+Init}!Vheap@{Vheap}}
\subsubsection[{elektra\+Vheap\+Init}]{\setlength{\rightskip}{0pt plus 5cm}Vheap$\ast$ elektra\+Vheap\+Init (
\begin{DoxyParamCaption}
\item[{Vheap\+Comp}]{comp, }
\item[{size\+\_\+t}]{min\+Size}
\end{DoxyParamCaption}
)}}\label{group__vheap_gaa57ffd6ed456de1b80d08a9c0cd0dc38}


Allocates vheap with size specified by parameter min\+Size. 

To construct a max heap the comparison function Vheap\+Comp (a, b), must return 1 on a $>$ b and 0 otherwise. For a min heap 1 on a $<$ b and 0 otherwise.


\begin{DoxyParams}{Parameters}
{\em comp} & the comparison function of the heap \\
\hline
{\em min\+Size} & the minimum size of the heap \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em a} & Vheap pointer \\
\hline
{\em N\+U\+L\+L} & error \\
\hline
\end{DoxyRetVals}
\hypertarget{group__vheap_ga038490c3f8458b51c916d1d8bb496e86}{\index{Vheap@{Vheap}!elektra\+Vheap\+Insert@{elektra\+Vheap\+Insert}}
\index{elektra\+Vheap\+Insert@{elektra\+Vheap\+Insert}!Vheap@{Vheap}}
\subsubsection[{elektra\+Vheap\+Insert}]{\setlength{\rightskip}{0pt plus 5cm}int elektra\+Vheap\+Insert (
\begin{DoxyParamCaption}
\item[{Vheap $\ast$}]{vheap, }
\item[{void $\ast$}]{data}
\end{DoxyParamCaption}
)}}\label{group__vheap_ga038490c3f8458b51c916d1d8bb496e86}


Inserts an element in the Vheap, by finding the right position. 

Resizes the memory first if needed.


\begin{DoxyParams}{Parameters}
{\em data} & the element \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & on error \\
\hline
{\em 1} & otherwise \\
\hline
\end{DoxyRetVals}
\hypertarget{group__vheap_gac300479bc8306d462346e9d27ad67d0f}{\index{Vheap@{Vheap}!elektra\+Vheap\+Is\+Empty@{elektra\+Vheap\+Is\+Empty}}
\index{elektra\+Vheap\+Is\+Empty@{elektra\+Vheap\+Is\+Empty}!Vheap@{Vheap}}
\subsubsection[{elektra\+Vheap\+Is\+Empty}]{\setlength{\rightskip}{0pt plus 5cm}int elektra\+Vheap\+Is\+Empty (
\begin{DoxyParamCaption}
\item[{const Vheap $\ast$}]{vheap}
\end{DoxyParamCaption}
)}}\label{group__vheap_gac300479bc8306d462346e9d27ad67d0f}


Checks if the heap is empty. 


\begin{DoxyRetVals}{Return values}
{\em 1} & on empty \\
\hline
{\em 0} & on non empty \\
\hline
{\em -\/1} & on error \\
\hline
\end{DoxyRetVals}
\hypertarget{group__vheap_gad2f5b57d9f3acef8c7679eb1795ca436}{\index{Vheap@{Vheap}!elektra\+Vheap\+Remove@{elektra\+Vheap\+Remove}}
\index{elektra\+Vheap\+Remove@{elektra\+Vheap\+Remove}!Vheap@{Vheap}}
\subsubsection[{elektra\+Vheap\+Remove}]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ elektra\+Vheap\+Remove (
\begin{DoxyParamCaption}
\item[{Vheap $\ast$}]{vheap}
\end{DoxyParamCaption}
)}}\label{group__vheap_gad2f5b57d9f3acef8c7679eb1795ca436}


Removes and returns an element from the Vheap, by taking the first element which is ordered by Vheap\+Comp, after removal the remaining elements get ordered again. 

Resizes the heap if needed.


\begin{DoxyRetVals}{Return values}
{\em the} & element \\
\hline
{\em N\+U\+L\+L} & on error \\
\hline
\end{DoxyRetVals}
