\hypertarget{BTREE_8h}{
\section{BTREE.h File Reference}
\label{BTREE_8h}\index{BTREE.h@{BTREE.h}}
}
Binary Tree, interface file. 



This graph shows which files directly or indirectly include this file:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=101pt]{BTREE_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__BTREE__node}{\_\-BTREE\_\-node}
\begin{CompactList}\small\item\em Definition of a node in a binary tree. \item\end{CompactList}\item 
struct \hyperlink{struct__BTREE}{\_\-BTREE}
\begin{CompactList}\small\item\em Context structure for a binary tree. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{BTREE_8h_a0}{
typedef \hyperlink{struct__BTREE__node}{\_\-BTREE\_\-node} \hyperlink{BTREE_8h_a0}{BTREE\_\-node}}
\label{BTREE_8h_a0}

\begin{CompactList}\small\item\em Typedef for struct {\em \hyperlink{struct__BTREE__node}{\_\-BTREE\_\-node}\/}. \item\end{CompactList}\item 
typedef int($\ast$ \hyperlink{BTREE_8h_a1}{BTREE\_\-compare} )(const void $\ast$key1, const void $\ast$key2)
\begin{CompactList}\small\item\em Comparison function used to sort the tree. \item\end{CompactList}\item 
typedef void($\ast$ \hyperlink{BTREE_8h_a2}{BTREE\_\-destroy} )(void $\ast$data)
\begin{CompactList}\small\item\em Call back function to destroy (freed) the data. \item\end{CompactList}\item 
\hypertarget{BTREE_8h_a3}{
typedef \hyperlink{struct__BTREE}{\_\-BTREE} \hyperlink{BTREE_8h_a3}{BTREE}}
\label{BTREE_8h_a3}

\begin{CompactList}\small\item\em Typedef for struct {\em \hyperlink{struct__BTREE}{\_\-BTREE}\/}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{BTREE_8h_a4}{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_8h_a5}{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_8h_a6}{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_8h_a7}{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_8h_a8}{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_8h_a9}{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_8h_a10}{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}\item 
static \_\-\_\-inline int \hyperlink{BTREE_8h_a11}{BTREE\_\-\_\-size} (\hyperlink{struct__BTREE}{BTREE} $\ast$tree)
\begin{CompactList}\small\item\em Returns the size (number of nodes) in the tree. \item\end{CompactList}\item 
static \_\-\_\-inline \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ \hyperlink{BTREE_8h_a12}{BTREE\_\-\_\-root} (\hyperlink{struct__BTREE}{BTREE} $\ast$tree)
\begin{CompactList}\small\item\em Returns the root of the tree. \item\end{CompactList}\item 
static \_\-\_\-inline void $\ast$ \hyperlink{BTREE_8h_a13}{BTREE\_\-\_\-data} (\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$node)
\begin{CompactList}\small\item\em Returns the data associated with the specified node. \item\end{CompactList}\item 
static \_\-\_\-inline \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ \hyperlink{BTREE_8h_a14}{BTREE\_\-\_\-left} (\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$node)
\begin{CompactList}\small\item\em Return the left node of the specified node. \item\end{CompactList}\item 
static \_\-\_\-inline \hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ \hyperlink{BTREE_8h_a15}{BTREE\_\-\_\-right} (\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$node)
\begin{CompactList}\small\item\em Return the right node of the specified node. \item\end{CompactList}\item 
static \_\-\_\-inline int \hyperlink{BTREE_8h_a16}{BTREE\_\-\_\-is\_\-eob} (\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$node)
\begin{CompactList}\small\item\em Tests if this node is a terminal node. \item\end{CompactList}\item 
static \_\-\_\-inline int \hyperlink{BTREE_8h_a17}{BTREE\_\-\_\-is\_\-leaf} (\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$node)
\begin{CompactList}\small\item\em Tests if this node is a leaf node. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Binary Tree, interface 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{Typedef Documentation}
\hypertarget{BTREE_8h_a1}{
\index{BTREE.h@{BTREE.h}!BTREE_compare@{BTREE\_\-compare}}
\index{BTREE_compare@{BTREE\_\-compare}!BTREE.h@{BTREE.h}}
\subsubsection[BTREE\_\-compare]{\setlength{\rightskip}{0pt plus 5cm}int \hyperlink{BTREE_8h_a1}{BTREE\_\-compare}}}
\label{BTREE_8h_a1}


Comparison function used to sort the tree. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em $<$0}]if key1 $<$ key2 \item[{\em =0}]if key1 = key2 \item[{\em $>$0}]if key1 $>$ key2\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em key1}]Pointer to the first data structure to be sorted \item[{\em key2}]Pointer to the second data structure to be sorted\end{description}
\end{Desc}
\hypertarget{BTREE_8h_a2}{
\index{BTREE.h@{BTREE.h}!BTREE_destroy@{BTREE\_\-destroy}}
\index{BTREE_destroy@{BTREE\_\-destroy}!BTREE.h@{BTREE.h}}
\subsubsection[BTREE\_\-destroy]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{BTREE_8h_a2}{BTREE\_\-destroy}}}
\label{BTREE_8h_a2}


Call back function to destroy (freed) the data. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em data}]The data to be destroyed (freed)\end{description}
\end{Desc}


\subsection{Function Documentation}
\hypertarget{BTREE_8h_a13}{
\index{BTREE.h@{BTREE.h}!BTREE__data@{BTREE\_\-\_\-data}}
\index{BTREE__data@{BTREE\_\-\_\-data}!BTREE.h@{BTREE.h}}
\subsubsection[BTREE\_\-\_\-data]{\setlength{\rightskip}{0pt plus 5cm}void $\ast$ BTREE\_\-\_\-data (\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ {\em node})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BTREE_8h_a13}


Returns the data associated with the specified node. 

\begin{Desc}
\item[Returns:]The data associate with the specified node\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em node}]The parent node.\end{description}
\end{Desc}
\hypertarget{BTREE_8h_a16}{
\index{BTREE.h@{BTREE.h}!BTREE__is_eob@{BTREE\_\-\_\-is\_\-eob}}
\index{BTREE__is_eob@{BTREE\_\-\_\-is\_\-eob}!BTREE.h@{BTREE.h}}
\subsubsection[BTREE\_\-\_\-is\_\-eob]{\setlength{\rightskip}{0pt plus 5cm}int BTREE\_\-\_\-is\_\-eob (\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ {\em node})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BTREE_8h_a16}


Tests if this node is a terminal node. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em ==0,not}]a terminal node \item[{\em !=0,is}]a terminal node\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em node}]The node to test.\end{description}
\end{Desc}
\hypertarget{BTREE_8h_a17}{
\index{BTREE.h@{BTREE.h}!BTREE__is_leaf@{BTREE\_\-\_\-is\_\-leaf}}
\index{BTREE__is_leaf@{BTREE\_\-\_\-is\_\-leaf}!BTREE.h@{BTREE.h}}
\subsubsection[BTREE\_\-\_\-is\_\-leaf]{\setlength{\rightskip}{0pt plus 5cm}int BTREE\_\-\_\-is\_\-leaf (\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ {\em node})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BTREE_8h_a17}


Tests if this node is a leaf node. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em ==0,not}]a leaf node \item[{\em !=0,is}]a leaf node\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em node}]The node to test.\end{description}
\end{Desc}
\hypertarget{BTREE_8h_a14}{
\index{BTREE.h@{BTREE.h}!BTREE__left@{BTREE\_\-\_\-left}}
\index{BTREE__left@{BTREE\_\-\_\-left}!BTREE.h@{BTREE.h}}
\subsubsection[BTREE\_\-\_\-left]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ BTREE\_\-\_\-left (\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ {\em node})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BTREE_8h_a14}


Return the left node of the specified node. 

\begin{Desc}
\item[Returns:]The left node of the specified node.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em node}]The parent node.\end{description}
\end{Desc}
\hypertarget{BTREE_8h_a15}{
\index{BTREE.h@{BTREE.h}!BTREE__right@{BTREE\_\-\_\-right}}
\index{BTREE__right@{BTREE\_\-\_\-right}!BTREE.h@{BTREE.h}}
\subsubsection[BTREE\_\-\_\-right]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ BTREE\_\-\_\-right (\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ {\em node})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BTREE_8h_a15}


Return the right node of the specified node. 

\begin{Desc}
\item[Returns:]The right node of the specified node.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em node}]The parent node.\end{description}
\end{Desc}
\hypertarget{BTREE_8h_a12}{
\index{BTREE.h@{BTREE.h}!BTREE__root@{BTREE\_\-\_\-root}}
\index{BTREE__root@{BTREE\_\-\_\-root}!BTREE.h@{BTREE.h}}
\subsubsection[BTREE\_\-\_\-root]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__BTREE__node}{BTREE\_\-node} $\ast$ BTREE\_\-\_\-root (\hyperlink{struct__BTREE}{BTREE} $\ast$ {\em tree})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BTREE_8h_a12}


Returns the root of the tree. 

\begin{Desc}
\item[Returns:]The root of the tree\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em tree}]The binary tree\end{description}
\end{Desc}
\hypertarget{BTREE_8h_a11}{
\index{BTREE.h@{BTREE.h}!BTREE__size@{BTREE\_\-\_\-size}}
\index{BTREE__size@{BTREE\_\-\_\-size}!BTREE.h@{BTREE.h}}
\subsubsection[BTREE\_\-\_\-size]{\setlength{\rightskip}{0pt plus 5cm}int BTREE\_\-\_\-size (\hyperlink{struct__BTREE}{BTREE} $\ast$ {\em tree})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BTREE_8h_a11}


Returns the size (number of nodes) in the tree. 

\begin{Desc}
\item[Returns:]The size (number of nodes) in the tree\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em tree}]The binary tree\end{description}
\end{Desc}
\hypertarget{BTREE_8h_a5}{
\index{BTREE.h@{BTREE.h}!BTREE_free@{BTREE\_\-free}}
\index{BTREE_free@{BTREE\_\-free}!BTREE.h@{BTREE.h}}
\subsubsection[BTREE\_\-free]{\setlength{\rightskip}{0pt plus 5cm}void BTREE\_\-free (\hyperlink{struct__BTREE}{BTREE} $\ast$ {\em tree})}}
\label{BTREE_8h_a5}


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_8h_a4}{
\index{BTREE.h@{BTREE.h}!BTREE_init@{BTREE\_\-init}}
\index{BTREE_init@{BTREE\_\-init}!BTREE.h@{BTREE.h}}
\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_8h_a4}


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_8h_a6}{
\index{BTREE.h@{BTREE.h}!BTREE_insertL@{BTREE\_\-insertL}}
\index{BTREE_insertL@{BTREE\_\-insertL}!BTREE.h@{BTREE.h}}
\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_8h_a6}


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_8h_a7}{
\index{BTREE.h@{BTREE.h}!BTREE_insertR@{BTREE\_\-insertR}}
\index{BTREE_insertR@{BTREE\_\-insertR}!BTREE.h@{BTREE.h}}
\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_8h_a7}


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_8h_a10}{
\index{BTREE.h@{BTREE.h}!BTREE_merge@{BTREE\_\-merge}}
\index{BTREE_merge@{BTREE\_\-merge}!BTREE.h@{BTREE.h}}
\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_8h_a10}


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_8h_a8}{
\index{BTREE.h@{BTREE.h}!BTREE_removeL@{BTREE\_\-removeL}}
\index{BTREE_removeL@{BTREE\_\-removeL}!BTREE.h@{BTREE.h}}
\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_8h_a8}


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_8h_a9}{
\index{BTREE.h@{BTREE.h}!BTREE_removeR@{BTREE\_\-removeR}}
\index{BTREE_removeR@{BTREE\_\-removeR}!BTREE.h@{BTREE.h}}
\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_8h_a9}


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}
