00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _LTI_TREE_H_
00034 #define _LTI_TREE_H_
00035
00036 #include "ltiObject.h"
00037 #include "ltiMathObject.h"
00038 #include "ltiException.h"
00039 #include "ltiMath.h"
00040 #include <list>
00041 #include <vector>
00042
00043 namespace lti {
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 template<class T>
00067 class tree : public mathObject {
00068
00069 public:
00070
00071
00072
00073 typedef T value_type;
00074
00075
00076
00077
00078 typedef int size_type;
00079
00080 class node;
00081 class iterator;
00082 class const_iterator;
00083
00084 protected:
00085
00086
00087
00088
00089 class nodeManager {
00090 public:
00091
00092
00093
00094
00095
00096 nodeManager(const int& n) : theSize(0),theDegree(n) {};
00097
00098
00099
00100
00101
00102
00103
00104
00105 node* createNode(const int& n,
00106 node& theNewParent,
00107 const T& newData=T()) {
00108 int idx;
00109
00110 if (freedNodes.empty()) {
00111
00112
00113
00114 idx = static_cast<int>(theNodes.size());
00115 node* newNode = new node(n,theNewParent,*this,newData,idx);
00116 theNodes.push_back(newNode);
00117
00118 } else {
00119
00120 idx = freedNodes.front();
00121 freedNodes.pop_front();
00122
00123 node* newNode = new node(n,theNewParent,*this,newData,idx);
00124 theNodes[idx] = newNode;
00125 }
00126
00127 theSize++;
00128
00129 return theNodes[idx];
00130 };
00131
00132
00133
00134
00135
00136
00137
00138
00139 node* createNode(const int& n,
00140 node* theNewParent,
00141 const T& newData=T()) {
00142 int idx;
00143
00144 if (freedNodes.empty()) {
00145
00146
00147
00148 idx = static_cast<int>(theNodes.size());
00149 node* newNode = new node(n,theNewParent,*this,newData,idx);
00150 theNodes.push_back(newNode);
00151
00152 } else {
00153
00154 idx = freedNodes.front();
00155 freedNodes.pop_front();
00156
00157 node* newNode = new node(n,theNewParent,*this,newData,idx);
00158 theNodes[idx] = newNode;
00159 }
00160
00161 theSize++;
00162
00163 return theNodes[idx];
00164 };
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 node* createNode(node& theNewParent,
00175 const T& newData=T()) {
00176 return createNode(theDegree,theNewParent,newData);
00177 };
00178
00179
00180
00181
00182
00183 void freeNode(node& theNode) {
00184 if (isNull(&theNode)) {
00185 return;
00186 }
00187
00188
00189 int i,ldegree;
00190 ldegree = theNode.degree();
00191 for (i=0;i<ldegree;++i) {
00192 if (theNode.isChildValid(i)) {
00193 freeNode(theNode.child(i));
00194 }
00195 }
00196
00197 int idx;
00198
00199 idx = theNode.index();
00200
00201 delete theNodes[idx];
00202 theNodes[idx]=0;
00203
00204 freedNodes.push_back(idx);
00205
00206 theSize--;
00207 };
00208
00209
00210
00211
00212 node* getNode(const int& idx) {
00213 if (idx<static_cast<int>(theNodes.size())) {
00214 return theNodes[idx];
00215 } else {
00216 return 0;
00217 }
00218 };
00219
00220
00221
00222
00223 const node* getNode(const int& idx) const {
00224 if (idx<static_cast<int>(theNodes.size())) {
00225 return theNodes[idx];
00226 } else {
00227 return 0;
00228 }
00229 };
00230
00231
00232
00233
00234 int getIndexOfNode(const node& aNode) const {
00235 return aNode.index();
00236 };
00237
00238
00239
00240
00241 const int& size() const {return theSize;}
00242
00243 protected:
00244
00245
00246
00247 std::vector<node*> theNodes;
00248
00249
00250
00251
00252
00253
00254
00255 std::list<int> freedNodes;
00256
00257
00258
00259
00260 int theSize;
00261
00262
00263
00264
00265 int theDegree;
00266 };
00267
00268 public:
00269
00270
00271
00272
00273 class node : public ioObject {
00274
00275
00276
00277
00278 friend class nodeManager;
00279 friend class tree<T>;
00280
00281 protected:
00282
00283
00284
00285 std::vector<node*> children;
00286
00287
00288
00289
00290 node* theParent;
00291
00292
00293
00294
00295 nodeManager* theOwner;
00296
00297
00298
00299
00300 T theData;
00301
00302
00303
00304
00305 int myIndex;
00306
00307
00308
00309
00310 inline const int& index() const {return myIndex;};
00311
00312
00313
00314
00315
00316 int theLevel;
00317
00318
00319 public:
00320
00321
00322
00323
00324
00325 node(const node& other) {
00326 copy(other);
00327 }
00328
00329
00330
00331
00332 virtual ~node() {
00333 }
00334
00335
00336
00337
00338
00339 bool isChildValid(const int& n) const {
00340 return ( n<degree() && children[n]!=0 );
00341 }
00342
00343
00344
00345
00346
00347
00348
00349
00350 const node& child(const int& n) const {
00351 assert(n<degree());
00352 return *children[n];
00353 }
00354
00355
00356
00357
00358
00359
00360
00361
00362 node& child(const int& n) {
00363 assert(n<degree());
00364
00365 return *children[n];
00366 }
00367
00368
00369
00370
00371
00372
00373
00374
00375 void setDegree(const int& n,bool clear = false) {
00376 int i;
00377 int ldegree = degree();
00378
00379 if (clear) {
00380 for (i=0;i<ldegree;++i) {
00381
00382 theOwner->freeNode(*children[i]);
00383 children[i]=0;
00384 }
00385 children.resize(0,0);
00386 } else {
00387 if (n<ldegree) {
00388 for (i=n;i<ldegree;++i) {
00389
00390
00391 theOwner->freeNode(*children[i]);
00392 children[i]=0;
00393 }
00394 }
00395 }
00396
00397 children.resize(n,0);
00398 };
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408 node& appendChild(const T& newChildData) {
00409
00410
00411
00412
00413 children.push_back(theOwner->createNode(*this,newChildData));
00414
00415 return *children[children.size()-1];
00416 };
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428 node& insertChild(const T& newChildData) {
00429 int i,ldegree;
00430
00431 ldegree = degree();
00432 i=0;
00433
00434 while ((i<ldegree) && (children[i]!=0)) {
00435 ++i;
00436 }
00437
00438 if (i>=ldegree) {
00439
00440 setDegree(ldegree+1,false);
00441 children[ldegree] =
00442 theOwner->createNode(*this,newChildData);
00443 i = ldegree;
00444 } else {
00445
00446 children[i] = theOwner->createNode(*this,newChildData);
00447 }
00448
00449 return *children[i];
00450 };
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460 node& insertChild(const int& n,const T& newChildData) {
00461 assert(n < degree());
00462
00463 node* newNode = theOwner->createNode(degree(),*this,newChildData);
00464
00465 if (notNull(children[n])) {
00466 if (newNode->degree()<1) {
00467 newNode->setDegree(1);
00468 }
00469 newNode->setChild(0,*children[n]);
00470 }
00471
00472 children[n]=newNode;
00473
00474 return *children[n];
00475 }
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485 node& moveChild(const int& m, const int& n) {
00486 assert(n < degree());
00487
00488 if (notNull(children[n])) {
00489 theOwner->freeNode(*children[n]);
00490 }
00491
00492 children[n] = children[m];
00493 children[m] = 0;
00494
00495 return *children[n];
00496 }
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508 node& insertSibling(const T& newSiblingData) {
00509 assert(!isRoot());
00510
00511 return parent().insertChild(newSiblingData);
00512 }
00513
00514
00515
00516
00517
00518
00519 node& deleteChild(const int& n) {
00520 assert(n<degree());
00521 if (notNull(children[n])) {
00522 theOwner->freeNode(*children[n]);
00523 children[n]=0;
00524 }
00525 return *this;
00526 }
00527
00528
00529
00530
00531 bool isRoot() const {
00532 return (isNull(theParent));
00533 }
00534
00535
00536
00537
00538
00539
00540
00541 node& parent() {
00542 return *theParent;
00543 };
00544
00545
00546
00547
00548 const node& parent() const {
00549 return *theParent;
00550 };
00551
00552
00553
00554
00555
00556 int degree() const {
00557 return static_cast<int>(children.size());
00558 };
00559
00560
00561
00562
00563
00564
00565
00566
00567 int numberOfChildren() const {
00568 int i,ldegree,noc;
00569 ldegree = degree();
00570 noc = 0;
00571 for (i=0;i<ldegree;++i) {
00572 if (isChildValid(i)) {
00573 noc++;
00574 }
00575 }
00576 return noc;
00577 }
00578
00579
00580
00581
00582 T& getData() {
00583 return theData;
00584 }
00585
00586
00587
00588
00589 const T& getData() const {
00590 return theData;
00591 }
00592
00593
00594
00595
00596 void setData(const T& newData) {
00597 theData = newData;
00598 }
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609 node& copy(const node& other) {
00610
00611 setData(other.getData());
00612
00613 setDegree(other.degree(),true);
00614
00615
00616 int i,ldegree;
00617
00618 ldegree = degree();
00619
00620 for (i=0;i<ldegree;++i) {
00621 if (other.isChildValid(i)) {
00622 children[i] = theOwner->createNode(other.child(i).degree(),
00623 *this,
00624 T());
00625 children[i]->copy(other.child(i));
00626 }
00627 }
00628
00629 theLevel = other.theLevel;
00630
00631 return *this;
00632 }
00633
00634
00635
00636
00637
00638
00639
00640
00641 int height() const {
00642 int i,ldegree,result;
00643 ldegree = degree();
00644 result = 0;
00645 for (i=0;i<ldegree;++i) {
00646 if (isChildValid(i)) {
00647 result = max(result,1+child(i).height());
00648 }
00649 }
00650
00651 return result;
00652 };
00653
00654
00655
00656
00657
00658
00659
00660 int subtreeSize() const {
00661 int i,ldegree,result;
00662 ldegree = degree();
00663 result = 1;
00664 for (i=0;i<ldegree;++i) {
00665 if (isChildValid(i)) {
00666 result += child(i).subtreeSize();
00667 }
00668 }
00669
00670 return result;
00671 };
00672
00673
00674
00675
00676
00677 const int& level() const {
00678 return theLevel;
00679 };
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689 int position() const {
00690 if (isRoot()) {
00691 return -1;
00692 }
00693
00694 int i,ldegree,idx;
00695
00696 ldegree = parent().degree();
00697 idx = -1;
00698 for (i=0;(idx<0) && (i<ldegree);++i) {
00699 if (isSameNode(parent().child(i))) {
00700 idx = i;
00701 }
00702 }
00703
00704 return idx;
00705 }
00706
00707
00708
00709
00710
00711
00712 bool equals(const node& other) {
00713 bool result;
00714
00715 result = (getData() == other.getData) &&
00716 (degree() == other.degree()) &&
00717 (size() == other.size()) &&
00718 (height() == other.height());
00719
00720 int i,ldegree;
00721 ldegree = degree();
00722 i=0;
00723 while ((i<ldegree) && (result)) {
00724 if (isChildValid(i) && other.isChildValid(i)) {
00725 result = result && (child(i).equals(other.child(i)));
00726 } else if (isChildValid(i) || other.isChildValid(i)) {
00727 result = false;
00728 }
00729 i++;
00730 }
00731 return result;
00732 }
00733
00734
00735
00736
00737 inline bool isSameNode(const node& other) const {
00738 return (this == &other);
00739 }
00740
00741
00742
00743
00744 inline bool isParentOf(const node& other) const {
00745 if (!other.isRoot()) {
00746 return (isSameNode(other.parent()));
00747 }
00748 return false;
00749 }
00750
00751
00752
00753
00754
00755 inline bool isSiblingOf(const node& other) const {
00756 if (!isRoot() && !other.isRoot() && !isSameNode(other)) {
00757 return (parent().isSameNode(other.parent()));
00758 }
00759 return false;
00760 }
00761
00762
00763
00764
00765
00766
00767 bool equalsTopology(const node& other) {
00768 bool result;
00769
00770 result = (degree() == other.degree());
00771
00772 int i,ldegree;
00773 ldegree = degree();
00774 i=0;
00775
00776 while ((i<ldegree) && (result)) {
00777 if (isChildValid(i) && other.isChildValid(i)) {
00778 result = result && (child(i).equalsTopology(other.child(i)));
00779 } else if (isChildValid(i) || other.isChildValid(i)) {
00780 result = false;
00781 }
00782 i++;
00783 }
00784
00785 return result;
00786 }
00787
00788
00789
00790
00791
00792
00793
00794 # ifndef _LTI_MSC_6
00795
00796
00797
00798
00799
00800
00801
00802 virtual bool write(ioHandler& handler,const bool complete=true) const
00803 # else
00804
00805
00806
00807
00808
00809
00810
00811 bool writeMS(ioHandler& handler,const bool complete=true) const
00812 # endif
00813 {
00814 bool b = true;
00815 if (complete) {
00816 b = handler.writeBegin();
00817 }
00818
00819
00820 b = b && lti::write(handler,theData);
00821 b = b && handler.writeDataSeparator();
00822
00823 const int ldegree = degree();
00824 b = b && handler.write(degree());
00825 b = b && handler.writeDataSeparator();
00826
00827
00828 b = b && handler.writeBegin();
00829
00830 int i;
00831 for (i=0;b && (i<ldegree);++i) {
00832 if (isChildValid(i)) {
00833 child(i).write(handler);
00834 } else {
00835
00836 handler.writeBegin();
00837 handler.writeEnd();
00838 }
00839 }
00840
00841 b = b && handler.writeEnd();
00842 b = b && handler.writeEOL();
00843
00844 if (complete) {
00845 b = b && handler.writeEnd();
00846 }
00847
00848 return b;
00849 }
00850
00851 # ifdef _LTI_MSC_6
00852
00853
00854
00855
00856
00857
00858
00859 bool write(ioHandler& handler,
00860 const bool complete=true) const {
00861
00862
00863 return writeMS(handler,complete);
00864 }
00865 # endif
00866
00867
00868 # ifndef _LTI_MSC_6
00869
00870
00871
00872
00873
00874
00875
00876 virtual bool read(ioHandler& handler,const bool complete=true)
00877 # else
00878
00879
00880
00881
00882
00883
00884
00885 bool readMS(ioHandler& handler,const bool complete=true)
00886 # endif
00887 {
00888 bool b = true;
00889 if (complete) {
00890 b = handler.readBegin();
00891 }
00892
00893
00894 b = b && lti::read(handler,theData);
00895 b = b && handler.readDataSeparator();
00896
00897
00898 int ldegree;
00899 b = b && handler.read(ldegree);
00900 setDegree(ldegree,true);
00901
00902 b = b && handler.readDataSeparator();
00903
00904
00905 b = b && handler.readBegin();
00906
00907 int i;
00908 for (i=0;b && (i<ldegree);++i) {
00909 b = b && handler.readBegin();
00910 if (!handler.tryEnd()) {
00911
00912 insertChild(i,T());
00913 b = b && child(i).read(handler,false);
00914 b = b && handler.readEnd();
00915 }
00916 }
00917
00918 b = b && handler.readEnd();
00919
00920 if (complete) {
00921 b = b && handler.readEnd();
00922 }
00923
00924 return b;
00925 }
00926
00927 # ifdef _LTI_MSC_6
00928
00929
00930
00931
00932
00933
00934
00935 bool read(ioHandler& handler,const bool complete=true) {
00936
00937
00938 return readMS(handler,complete);
00939 }
00940 # endif
00941
00942
00943
00944 protected:
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956 node(const int& n,
00957 node& theNewParent,
00958 nodeManager& owner,
00959 const T& newData,
00960 const int& index)
00961 : theParent(&theNewParent),theOwner(&owner),
00962 theData(newData),myIndex(index),theLevel(0) {
00963 children.resize(n,0);
00964 if (notNull(theParent)) {
00965 theLevel = theParent->level()+1;
00966 }
00967 };
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979 node(const int& n,
00980 node* theNewParent,
00981 nodeManager& owner,
00982 const T& newData,
00983 const int& index)
00984 : theParent(theNewParent),theOwner(&owner),
00985 theData(newData),myIndex(index),theLevel(0) {
00986 children.resize(n,0);
00987 if (notNull(theParent)) {
00988 theLevel = theParent->level()+1;
00989 }
00990 };
00991
00992
00993
00994
00995 void setParent(node& newParent) {
00996 theParent = &newParent;
00997 updateLevels();
00998 }
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008 void setChild(const int& n,node& newChild) {
01009 assert(n<degree());
01010 children[n] = &newChild;
01011 newChild.theParent = this;
01012 updateLevels();
01013 }
01014
01015
01016
01017
01018 void updateLevels() {
01019 if (notNull(theParent)) {
01020 theLevel = theParent->level()+1;
01021 }
01022
01023 const int& ldegree = degree();
01024 const int tmpLevel = theLevel+1;
01025 int i;
01026
01027 for (i=0;i<ldegree;++i) {
01028 if (isChildValid(i) && (child(i).level() != tmpLevel)) {
01029 child(i).updateLevels();
01030 }
01031 }
01032 }
01033
01034 };
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059 class iterator {
01060
01061 # ifdef _LTI_MSC_6
01062 friend class const_iterator;
01063 # else
01064 friend class tree<T>::const_iterator;
01065 # endif
01066
01067 friend class tree<T>;
01068 protected:
01069
01070
01071
01072 std::list<int> stack;
01073
01074
01075
01076
01077 node* pointedNode;
01078
01079
01080
01081
01082 nodeManager* theOwner;
01083
01084
01085
01086
01087 explicit iterator(node& theNode,nodeManager& owner)
01088 : pointedNode(&theNode),theOwner(&owner) {};
01089
01090 public:
01091
01092
01093
01094 iterator() : pointedNode(0),theOwner(0) {};
01095
01096
01097
01098
01099
01100 iterator(const iterator& other)
01101 : stack(other.stack),pointedNode(other.pointedNode),
01102 theOwner(other.theOwner) {};
01103
01104
01105
01106
01107 inline iterator& operator++() {
01108 assert(notNull(pointedNode));
01109
01110 int i;
01111
01112 const int size = pointedNode->degree() - 1;
01113
01114 for (i=size;i>=0;i--) {
01115 if (pointedNode->isChildValid(i)) {
01116 stack.push_front(theOwner->getIndexOfNode(pointedNode->child(i)));
01117 }
01118 }
01119
01120 if (stack.empty()) {
01121 pointedNode = 0;
01122 } else {
01123 do {
01124 const int idx = stack.front();
01125 stack.pop_front();
01126
01127 pointedNode = theOwner->getNode(idx);
01128 } while (isNull(pointedNode) && (!stack.empty()));
01129
01130 }
01131
01132 return *this;
01133 };
01134
01135
01136
01137
01138 inline bool operator==(const iterator& other) const {
01139 return (pointedNode == other.pointedNode);
01140 };
01141
01142
01143
01144
01145 inline bool operator!=(const iterator& other) const {
01146 return (pointedNode != other.pointedNode);
01147 };
01148
01149
01150
01151
01152 inline node& operator*() {return *pointedNode;};
01153
01154
01155
01156
01157 inline iterator& operator=(const iterator& other) {
01158 pointedNode = other.pointedNode;
01159 stack = other.stack;
01160 theOwner = other.theOwner;
01161 return *this;
01162 };
01163 };
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181 class const_iterator {
01182 friend class tree<T>;
01183 protected:
01184
01185
01186
01187 std::list<int> stack;
01188
01189
01190
01191
01192 const node* pointedNode;
01193
01194
01195
01196
01197 const nodeManager* theOwner;
01198
01199
01200
01201
01202 explicit const_iterator(const node& theNode,const nodeManager& owner)
01203 : pointedNode(&theNode),theOwner(&owner) {};
01204
01205 public:
01206
01207
01208
01209 const_iterator() : pointedNode(0),theOwner(0) {};
01210
01211
01212
01213
01214 const_iterator(const const_iterator& other)
01215 : stack(other.stack),pointedNode(other.pointedNode),
01216 theOwner(other.theOwner) {};
01217
01218
01219
01220
01221 const_iterator(const iterator& other)
01222 : stack(other.stack),pointedNode(other.pointedNode),
01223 theOwner(other.theOwner) {
01224 };
01225
01226
01227
01228
01229 inline const_iterator& operator++() {
01230 assert(notNull(pointedNode));
01231
01232 int i;
01233
01234 const int size = pointedNode->degree() - 1;
01235
01236 for (i=size;i>=0;i--) {
01237 if (pointedNode->isChildValid(i)) {
01238 stack.push_front(theOwner->getIndexOfNode(pointedNode->child(i)));
01239 }
01240 }
01241
01242 if (stack.empty()) {
01243 pointedNode = 0;
01244 } else {
01245 do {
01246 const int idx = stack.front();
01247 stack.pop_front();
01248
01249 pointedNode = theOwner->getNode(idx);
01250 } while (isNull(pointedNode) && (!stack.empty()));
01251 }
01252
01253 return *this;
01254 };
01255
01256
01257
01258
01259
01260 inline const_iterator operator++(int) {
01261 assert(notNull(pointedNode));
01262 const_iterator tmp(*this);
01263
01264 int i;
01265
01266 const int size = pointedNode->degree() - 1;
01267
01268 for (i=size;i>=0;i--) {
01269 if (pointedNode->isChildValid(i)) {
01270 stack.push_front(theOwner->getIndexOfNode(pointedNode->child(i)));
01271 }
01272 }
01273
01274 if (stack.empty()) {
01275 pointedNode = 0;
01276 } else {
01277 do {
01278 const int idx = stack.front();
01279 stack.pop_front();
01280
01281 pointedNode = theOwner->getNode(idx);
01282 } while (isNull(pointedNode) && (!stack.empty()));
01283 }
01284
01285 return tmp;
01286 };
01287
01288
01289
01290
01291 inline bool operator==(const const_iterator& other) const {
01292 return (pointedNode == other.pointedNode);
01293 };
01294
01295
01296
01297
01298 inline bool operator!=(const const_iterator& other) const {
01299 return (pointedNode != other.pointedNode);
01300 };
01301
01302
01303
01304
01305 inline bool operator==(const iterator& other) const {
01306 return (pointedNode == other.pointedNode);
01307 };
01308
01309
01310
01311
01312 inline bool operator!=(const iterator& other) const {
01313 return (pointedNode != other.pointedNode);
01314 };
01315
01316
01317
01318
01319 inline const node& operator*() const {return *pointedNode;};
01320
01321
01322
01323
01324 inline const_iterator& operator=(const const_iterator& other) {
01325 pointedNode = other.pointedNode;
01326 stack = other.stack;
01327 theOwner = other.theOwner;
01328 return *this;
01329 };
01330
01331
01332
01333
01334 inline const_iterator& operator=(const iterator& other) {
01335 pointedNode = other.pointedNode;
01336 stack = other.stack;
01337 theOwner = other.theOwner;
01338 return *this;
01339 };
01340 };
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358 tree(const int& n=0);
01359
01360
01361
01362
01363
01364
01365 tree(const tree<T>& other);
01366
01367
01368
01369
01370 virtual ~tree();
01371
01372
01373
01374
01375 const char* getTypeName() const {return "tree";};
01376
01377
01378
01379
01380 inline size_type size() const;
01381
01382
01383
01384
01385
01386 inline size_type height() const;
01387
01388
01389
01390
01391
01392
01393
01394 inline const_iterator begin() const;
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421 inline iterator begin();
01422
01423
01424
01425
01426
01427 inline const_iterator end() const;
01428
01429
01430
01431
01432
01433 inline iterator end();
01434
01435
01436
01437
01438 inline iterator getIteratorTo(node& aNode);
01439
01440
01441
01442
01443 inline const_iterator getIteratorTo(const node& aNode) const;
01444
01445
01446
01447
01448
01449 void clear();
01450
01451
01452
01453
01454
01455
01456
01457 void fill(const T& iniValue);
01458
01459
01460
01461
01462
01463 node& root();
01464
01465
01466
01467
01468
01469 const node& root() const;
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481 void pushRoot(const T& newData);
01482
01483
01484
01485
01486
01487
01488 tree<T>& copy(const tree<T>& other);
01489
01490
01491
01492
01493
01494 virtual mathObject* clone() const;
01495
01496
01497
01498
01499 bool empty() const;
01500
01501
01502
01503
01504
01505
01506 bool equals(const tree<T>& other) const;
01507
01508
01509
01510
01511
01512
01513 inline bool operator==(const tree<T>& other) const;
01514
01515
01516
01517
01518
01519
01520 tree<T>& operator=(const tree<T>& other) {return copy(other);};
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530 virtual bool write(ioHandler& handler,
01531 const bool complete=true) const;
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541 virtual bool read(ioHandler& handler,const bool complete=true);
01542
01543
01544 protected:
01545
01546
01547
01548 node* theRoot;
01549
01550
01551
01552
01553 int rootDegree;
01554
01555
01556
01557
01558
01559 nodeManager theNodeManager;
01560
01561 };
01562 }
01563
01564 #include "ltiTree_inline.h"
01565 #include "ltiTree_template.h"
01566
01567
01568 #endif