\hypertarget{BTREE_8c}{
\section{BTREE.c File Reference}
\label{BTREE_8c}\index{BTREE.c@{BTREE.c}}
}
Binary Tree, implementation file. 

{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include \char`\"{}LDT/BTREE.h\char`\"{}}\par


Include dependency graph for BTREE.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=115pt]{BTREE_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{BTREE_8c_a0}{BTREE\_\-init} (\hyperlink{struct__BTREE}{BTREE} $\ast$tree, \hyperlink{BTREE_8h_a2}{BTREE\_\-destroy} destroy)
\begin{CompactList}\small\item\em Initializes the context control structure. \item\end{CompactList}\item 
void \hyperlink{BTREE_8c_a1}{BTREE\_\-free} (\hyperlink{struct__BTREE}{BTREE} $\ast$tree)
\begin{CompactList}\small\item\em Frees all the data associated with the specified tree. \item\end{CompactList}\item 
int \hyperlink{BTREE_8c_a2}{BTREE\_\-insert\-L} (\hyperlink{struct__BTREE}{BTREE} $\ast$tree, \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$node, const void $\ast$data)
\begin{CompactList}\small\item\em Inserts the data as the left node of the specified node. \item\end{CompactList}\item 
int \hyperlink{BTREE_8c_a3}{BTREE\_\-insert\-R} (\hyperlink{struct__BTREE}{BTREE} $\ast$tree, \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$node, const void $\ast$data)
\begin{CompactList}\small\item\em Inserts the data as the right node of the specified node. \item\end{CompactList}\item 
void \hyperlink{BTREE_8c_a4}{BTREE\_\-remove\-L} (\hyperlink{struct__BTREE}{BTREE} $\ast$tree, \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$node)
\begin{CompactList}\small\item\em Removes the left node and all its branches. \item\end{CompactList}\item 
void \hyperlink{BTREE_8c_a5}{BTREE\_\-remove\-R} (\hyperlink{struct__BTREE}{BTREE} $\ast$tree, \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$node)
\begin{CompactList}\small\item\em Removes the right node and all its branches. \item\end{CompactList}\item 
int \hyperlink{BTREE_8c_a6}{BTREE\_\-merge} (\hyperlink{struct__BTREE}{BTREE} $\ast$merge, \hyperlink{struct__BTREE}{BTREE} $\ast$left, \hyperlink{struct__BTREE}{BTREE} $\ast$right, const void $\ast$data)
\begin{CompactList}\small\item\em Merges two trees into a single parent tree, adding the data of the merged tree. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Binary Tree, implementation file. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\footnotesize\begin{verbatim}CVS $Id
\end{verbatim}
\normalsize


\begin{Desc}
\item[Warning:]In their current state, these routines are not fit for Flight use. They can be used in studies. However they malloc all over the place and involve recursive calling techniques, neither of is appropriate for Flight code.\end{Desc}


\subsection{Function Documentation}
\hypertarget{BTREE_8c_a1}{
\index{BTREE.c@{BTREE.c}!BTREE_free@{BTREE\_\-free}}
\index{BTREE_free@{BTREE\_\-free}!BTREE.c@{BTREE.c}}
\subsubsection[BTREE\_\-free]{\setlength{\rightskip}{0pt plus 5cm}void BTREE\_\-free (\hyperlink{struct__BTREE}{BTREE} $\ast$ {\em tree})}}
\label{BTREE_8c_a1}


Frees all the data associated with the specified tree. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em tree}]The root of the tree to free\end{description}
\end{Desc}
\hypertarget{BTREE_8c_a0}{
\index{BTREE.c@{BTREE.c}!BTREE_init@{BTREE\_\-init}}
\index{BTREE_init@{BTREE\_\-init}!BTREE.c@{BTREE.c}}
\subsubsection[BTREE\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void BTREE\_\-init (\hyperlink{struct__BTREE}{BTREE} $\ast$ {\em tree}, \hyperlink{BTREE_8h_a2}{BTREE\_\-destroy} {\em destroy})}}
\label{BTREE_8c_a0}


Initializes the context control structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em tree}]The binary tree context to initialize \item[{\em destroy}]Callback function to free the nodes in a binary tree, may be NULL.\end{description}
\end{Desc}
\hypertarget{BTREE_8c_a2}{
\index{BTREE.c@{BTREE.c}!BTREE_insertL@{BTREE\_\-insertL}}
\index{BTREE_insertL@{BTREE\_\-insertL}!BTREE.c@{BTREE.c}}
\subsubsection[BTREE\_\-insertL]{\setlength{\rightskip}{0pt plus 5cm}int BTREE\_\-insert\-L (\hyperlink{struct__BTREE}{BTREE} $\ast$ {\em tree}, \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ {\em node}, const void $\ast$ {\em data})}}
\label{BTREE_8c_a2}


Inserts the data as the left node of the specified node. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0,if}]successful \item[{\em -1,if}]failure\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em tree}]The binary tree \item[{\em node}]The parent node, may be NULL if this is the first node \item[{\em data}]Pointer to the data to be inserted\end{description}
\end{Desc}
Failure can occur if\begin{itemize}
\item {\em node\/} is specified as NULL, but the tree is not empty\item the left node of {\em node\/} is already filled\item allocation of a new node fails\end{itemize}
\hypertarget{BTREE_8c_a3}{
\index{BTREE.c@{BTREE.c}!BTREE_insertR@{BTREE\_\-insertR}}
\index{BTREE_insertR@{BTREE\_\-insertR}!BTREE.c@{BTREE.c}}
\subsubsection[BTREE\_\-insertR]{\setlength{\rightskip}{0pt plus 5cm}int BTREE\_\-insert\-R (\hyperlink{struct__BTREE}{BTREE} $\ast$ {\em tree}, \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ {\em node}, const void $\ast$ {\em data})}}
\label{BTREE_8c_a3}


Inserts the data as the right node of the specified node. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0,if}]successful \item[{\em -1,if}]failure\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em tree}]The binary tree \item[{\em node}]The parent node, may be NULL if this is the first node \item[{\em data}]Pointer to the data to be inserted\end{description}
\end{Desc}
Failure can occur if\begin{itemize}
\item {\em node\/} is specified as NULL, but the tree is not empty\item the right node of {\em node\/} is already filled\item allocation of a new node fails\end{itemize}
\hypertarget{BTREE_8c_a6}{
\index{BTREE.c@{BTREE.c}!BTREE_merge@{BTREE\_\-merge}}
\index{BTREE_merge@{BTREE\_\-merge}!BTREE.c@{BTREE.c}}
\subsubsection[BTREE\_\-merge]{\setlength{\rightskip}{0pt plus 5cm}int BTREE\_\-merge (\hyperlink{struct__BTREE}{BTREE} $\ast$ {\em merge}, \hyperlink{struct__BTREE}{BTREE} $\ast$ {\em left}, \hyperlink{struct__BTREE}{BTREE} $\ast$ {\em right}, const void $\ast$ {\em data})}}
\label{BTREE_8c_a6}


Merges two trees into a single parent tree, adding the data of the merged tree. 

\begin{Desc}
\item[Returns:]Status\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em merge}]The merged tree \item[{\em left}]The left tree to merge \item[{\em right}]The right tree to merge \item[{\em data}]The data to add\end{description}
\end{Desc}
\hypertarget{BTREE_8c_a4}{
\index{BTREE.c@{BTREE.c}!BTREE_removeL@{BTREE\_\-removeL}}
\index{BTREE_removeL@{BTREE\_\-removeL}!BTREE.c@{BTREE.c}}
\subsubsection[BTREE\_\-removeL]{\setlength{\rightskip}{0pt plus 5cm}void BTREE\_\-remove\-L (\hyperlink{struct__BTREE}{BTREE} $\ast$ {\em tree}, \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ {\em node})}}
\label{BTREE_8c_a4}


Removes the left node and all its branches. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em tree}]The binary tree \item[{\em node}]The parent node\end{description}
\end{Desc}
\hypertarget{BTREE_8c_a5}{
\index{BTREE.c@{BTREE.c}!BTREE_removeR@{BTREE\_\-removeR}}
\index{BTREE_removeR@{BTREE\_\-removeR}!BTREE.c@{BTREE.c}}
\subsubsection[BTREE\_\-removeR]{\setlength{\rightskip}{0pt plus 5cm}void BTREE\_\-remove\-R (\hyperlink{struct__BTREE}{BTREE} $\ast$ {\em tree}, \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ {\em node})}}
\label{BTREE_8c_a5}


Removes the right node and all its branches. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em tree}]The binary tree \item[{\em node}]The parent node\end{description}
\end{Desc}
