Claw  1.7.3
impl/binary_node.tpp
Go to the documentation of this file.
00001 /*
00002   CLAW - a C++ Library Absolutely Wonderful
00003 
00004   CLAW is a free library without any particular aim but being useful to 
00005   anyone.
00006 
00007   Copyright (C) 2005-2011 Julien Jorge
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023   contact: julien.jorge@gamned.org
00024 */
00031 #include <cstddef>
00032 
00033 /*---------------------------------------------------------------------------*/
00038 template< class U >
00039 claw::binary_node<U>::binary_node() 
00040   : left(NULL), right(NULL)
00041 {
00042 
00043 } //binary_node()
00044 
00045 /*---------------------------------------------------------------------------*/
00050 template< class U >
00051 claw::binary_node<U>::binary_node( const binary_node& that )
00052 {
00053   if (that.left)
00054     left = new U( * that.left );
00055   else
00056     left = NULL;
00057 
00058   if ( that.right )
00059     right = new U( * that.right );
00060   else
00061     right = NULL;
00062 } // binary_node() [copy constructor]
00063 
00064 /*---------------------------------------------------------------------------*/
00069 template< class U >
00070 void claw::binary_node<U>::clear()
00071 {
00072   left = NULL;
00073   right = NULL;
00074 } // clear()
00075 
00076 /*---------------------------------------------------------------------------*/
00081 template< class U >
00082 claw::binary_node<U>::~binary_node()
00083 {
00084   if (left)
00085     delete left;
00086 
00087   if (right)
00088     delete right;
00089 } // ~binary_node() [destructor]