File indexing completed on 2024-07-21 08:05:24

0001 /***************************************************************************
0002  *   Copyright (C) 2004-2005 by Daniel Clarke                              *
0003  *   daniel.jc@gmail.com                                               *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 
0021 #include "btreenode.h"
0022 #include "pic14.h"
0023 
0024 BTreeNode::BTreeNode()
0025 {
0026     m_parent = nullptr;
0027     m_left = nullptr;
0028     m_right = nullptr;
0029     m_type = unset;
0030 }
0031 
0032 BTreeNode::BTreeNode(BTreeNode *p, BTreeNode *l, BTreeNode *r)
0033 {
0034     m_parent = p;
0035     m_left = l;
0036     m_right = r;
0037 }
0038 
0039 BTreeNode::~BTreeNode()
0040 {
0041     // Must not delete children as might be unlinking!!! deleteChildren();
0042 }
0043 
0044 void BTreeNode::deleteChildren()
0045 {
0046     if(m_left)
0047     {
0048         m_left->deleteChildren();
0049         delete m_left;
0050     }
0051     if(m_right)
0052     {
0053         m_right->deleteChildren();
0054         delete m_right;
0055     }
0056     
0057     m_left = nullptr;
0058     m_right = nullptr;
0059     
0060     return;
0061 }
0062 
0063 // void BTreeNode::printTree()
0064 // {
0065 //  
0066 // }