| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester |
| 3 | Copyright (C) 2015-2017 Dmitry Tsarkov |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #ifndef TSTTREE_H |
| 21 | #define TSTTREE_Hcxx . . $ `Kernel/tsttree.h:21:9`! |
| 22 | |
| 23 | template < class T > |
| 24 | class TsTTreecxx . . $ TsTTree# |
| 25 | { |
| 26 | private: // members |
| 27 | /// element in the tree node |
| 28 | T elemcxx . . $ TsTTree#elem.; |
| 29 | /// pointer to left subtree |
| 30 | TsTTree *leftcxx . . $ TsTTree#left.; |
| 31 | /// pointer to right subtree |
| 32 | TsTTree *rightcxx . . $ TsTTree#right.; |
| 33 | |
| 34 | public: // interface |
| 35 | /// default c'tor |
| 36 | explicit TsTTreecxx . . $ TsTTree#`TsTTree<T>`(951218c3cf21108). ( const T& Init, TsTTree *l = nullptr, TsTTree *r = nullptr ) |
| 37 | : elemcxx . . $ TsTTree#elem.(Init) |
| 38 | , leftcxx . . $ TsTTree#left.(l) |
| 39 | , rightcxx . . $ TsTTree#right.(r) |
| 40 | {} |
| 41 | /// no copy c'tor |
| 42 | TsTTreecxx . . $ TsTTree#`TsTTree<T>`(88511f4b7a104e51). ( const TsTTree& ) = delete; |
| 43 | /// no assignment |
| 44 | TsTTree& operatorcxx . . $ TsTTree#`operator=`(62021f086e1bf1b8). = ( const TsTTree& ) = delete; |
| 45 | /// d'tor |
| 46 | ~cxx . . $ TsTTree#`~TsTTree<T>`(49f6e7a06ebc5aa8).TsTTree() = default; |
| 47 | |
| 48 | // access to members |
| 49 | |
| 50 | T& Elementcxx . . $ TsTTree#Element(19b2b6f17af048b). ( void ) { return elemcxx . . $ TsTTree#elem.; } |
| 51 | const T& Elementcxx . . $ TsTTree#Element(ea465e50d690edfe). ( void ) const { return elemcxx . . $ TsTTree#elem.; } |
| 52 | |
| 53 | TsTTree* Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7). ( void ) const { return leftcxx . . $ TsTTree#left.; } |
| 54 | TsTTree* Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7). ( void ) const { return rightcxx . . $ TsTTree#right.; } |
| 55 | |
| 56 | void SetLeftcxx . . $ TsTTree#SetLeft(4e90cc9f278c70d6). ( TsTTree *l ) { leftcxx . . $ TsTTree#left. = l; } |
| 57 | void SetRightcxx . . $ TsTTree#SetRight(4e90cc9f278c70d6). ( TsTTree *r ) { rightcxx . . $ TsTTree#right. = r; } |
| 58 | |
| 59 | TsTTree* clonecxx . . $ TsTTree#clone(f4b2f47551fb31d7). ( void ) const |
| 60 | { |
| 61 | TsTTree* p = new TsTTree(Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).()); |
| 62 | if ( leftcxx . . $ TsTTree#left. ) |
| 63 | p->SetLeftcxx . . $ TsTTree#SetLeft(4e90cc9f278c70d6).(leftcxx . . $ TsTTree#left.->clonecxx . . $ TsTTree#clone(f4b2f47551fb31d7).()); |
| 64 | if ( rightcxx . . $ TsTTree#right. ) |
| 65 | p->SetRightcxx . . $ TsTTree#SetRight(4e90cc9f278c70d6).(rightcxx . . $ TsTTree#right.->clonecxx . . $ TsTTree#clone(f4b2f47551fb31d7).()); |
| 66 | return p; |
| 67 | } |
| 68 | }; // TsTTree |
| 69 | |
| 70 | /// delete the whole tree |
| 71 | template <typename T> |
| 72 | void deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2). ( TsTTreecxx . . $ TsTTree#<T>* t ) |
| 73 | { |
| 74 | if ( t ) |
| 75 | { |
| 76 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(t->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).()); |
| 77 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(t->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).()); |
| 78 | delete t; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | #endif |