|
FreeLing
3.0
|
00001 00002 // 00003 // STL-like n-ary tree template 00004 // 00005 // Copyright (C) 2006 TALP Research Center 00006 // Universitat Politecnica de Catalunya 00007 // 00008 // This program is free software; you can redistribute it 00009 // and/or modify it under the terms of the GNU General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 3 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 51 Franklin St, 5th Floor, Boston, MA 02110-1301 USA 00021 // 00022 // contact: Lluis Padro (padro@lsi.upc.es) 00023 // TALP Research Center 00024 // despatx Omega.S112 - Campus Nord UPC 00025 // 08034 Barcelona. SPAIN 00026 // 00028 00029 #ifndef _TREE_TEMPLATE 00030 #define _TREE_TEMPLATE 00031 00032 00033 // predeclarations 00034 template <class T> class tree; 00035 00036 template <class T> class generic_iterator; 00037 template <class T> class generic_const_iterator; 00038 00039 template <class T> class preorder_iterator; 00040 template <class T> class const_preorder_iterator; 00041 template <class T> class sibling_iterator; 00042 template <class T> class const_sibling_iterator; 00043 00045 template<class T, class N> 00046 class tree_iterator { 00047 protected: 00048 N *pnode; 00049 public: 00050 tree_iterator(); 00051 tree_iterator(tree<T> *); 00052 tree_iterator(const tree_iterator<T,N> &); 00053 ~tree_iterator(); 00054 00055 const tree<T>& operator*() const; 00056 const tree<T>* operator->() const; 00057 bool operator==(const tree_iterator<T,N> &) const; 00058 bool operator!=(const tree_iterator<T,N> &) const; 00059 }; 00060 00061 template<class T> 00062 class generic_iterator : public tree_iterator<T,tree<T> > { 00063 friend class generic_const_iterator<T>; 00064 public: 00065 generic_iterator(); 00066 generic_iterator(tree<T> *); 00067 generic_iterator(const generic_iterator<T> &); 00068 tree<T>& operator*() const; 00069 tree<T>* operator->() const; 00070 ~generic_iterator(); 00071 }; 00072 00073 template<class T> 00074 class generic_const_iterator : public tree_iterator<T,const tree<T> > { 00075 public: 00076 generic_const_iterator(); 00077 generic_const_iterator(const generic_iterator<T> &); 00078 generic_const_iterator(const generic_const_iterator<T> &); 00079 generic_const_iterator(tree<T> *); 00080 generic_const_iterator(const tree<T> *); 00081 ~generic_const_iterator(); 00082 }; 00083 00084 00086 00087 template<class T> 00088 class sibling_iterator : public generic_iterator<T> { 00089 public: 00090 sibling_iterator(); 00091 sibling_iterator(const sibling_iterator<T> &); 00092 sibling_iterator(tree<T> *); 00093 ~sibling_iterator(); 00094 00095 sibling_iterator& operator++(); 00096 sibling_iterator& operator--(); 00097 sibling_iterator operator++(int); 00098 sibling_iterator operator--(int); 00099 }; 00100 00101 template<class T> 00102 class const_sibling_iterator : public generic_const_iterator<T> { 00103 public: 00104 const_sibling_iterator(); 00105 const_sibling_iterator(const const_sibling_iterator<T> &); 00106 const_sibling_iterator(const sibling_iterator<T> &); 00107 const_sibling_iterator(tree<T> *); 00108 ~const_sibling_iterator(); 00109 00110 const_sibling_iterator& operator++(); 00111 const_sibling_iterator& operator--(); 00112 const_sibling_iterator operator++(int); 00113 const_sibling_iterator operator--(int); 00114 }; 00115 00116 00118 template<class T> 00119 class preorder_iterator : public generic_iterator<T> { 00120 public: 00121 preorder_iterator(); 00122 preorder_iterator(const preorder_iterator<T> &); 00123 preorder_iterator(tree<T> *); 00124 preorder_iterator(const sibling_iterator<T> &); 00125 ~preorder_iterator(); 00126 00127 preorder_iterator& operator++(); 00128 preorder_iterator& operator--(); 00129 preorder_iterator operator++(int); 00130 preorder_iterator operator--(int); 00131 }; 00132 00133 template<class T> 00134 class const_preorder_iterator : public generic_const_iterator<T> { 00135 public: 00136 const_preorder_iterator(); 00137 const_preorder_iterator(tree<T> *); 00138 const_preorder_iterator(const tree<T> *); 00139 const_preorder_iterator(const const_preorder_iterator<T> &); 00140 const_preorder_iterator(const preorder_iterator<T> &); 00141 const_preorder_iterator(const const_sibling_iterator<T> &); 00142 const_preorder_iterator(const sibling_iterator<T> &); 00143 ~const_preorder_iterator(); 00144 00145 const_preorder_iterator& operator++(); 00146 const_preorder_iterator& operator--(); 00147 const_preorder_iterator operator++(int); 00148 const_preorder_iterator operator--(int); 00149 }; 00150 00151 template <class T> 00152 class tree { 00153 friend class preorder_iterator<T>; 00154 friend class const_preorder_iterator<T>; 00155 friend class sibling_iterator<T>; 00156 friend class const_sibling_iterator<T>; 00157 00158 private: 00159 bool isempty; 00160 tree *parent; // parent node 00161 tree *first,*last; // first/last child 00162 tree *prev,*next; // prev/next sibling 00163 void clone(const tree<T>&); 00164 00165 public: 00166 T info; 00167 typedef class generic_iterator<T> generic_iterator; 00168 typedef class generic_const_iterator<T> generic_const_iterator; 00169 typedef class preorder_iterator<T> preorder_iterator; 00170 typedef class const_preorder_iterator<T> const_preorder_iterator; 00171 typedef class sibling_iterator<T> sibling_iterator; 00172 typedef class const_sibling_iterator<T> const_sibling_iterator; 00173 typedef preorder_iterator iterator; 00174 typedef const_preorder_iterator const_iterator; 00175 00176 tree(); 00177 tree(const T&); 00178 tree(const tree<T>&); 00179 tree(const typename tree<T>::preorder_iterator&); 00180 ~tree(); 00181 tree<T>& operator=(const tree<T>&); 00182 00183 unsigned int num_children() const; 00184 sibling_iterator nth_child(unsigned int) const; 00185 iterator get_parent() const; 00186 tree<T> & nth_child_ref(unsigned int) const; 00187 T& get_info(); 00188 void append_child(const tree<T> &); 00189 void hang_child(tree<T> &, bool=true); 00190 void clear(); 00191 bool empty() const; 00192 00193 sibling_iterator sibling_begin(); 00194 const_sibling_iterator sibling_begin() const; 00195 sibling_iterator sibling_end(); 00196 const_sibling_iterator sibling_end() const; 00197 sibling_iterator sibling_rbegin(); 00198 const_sibling_iterator sibling_rbegin() const; 00199 sibling_iterator sibling_rend(); 00200 const_sibling_iterator sibling_rend() const; 00201 00202 preorder_iterator begin(); 00203 const_preorder_iterator begin() const; 00204 preorder_iterator end(); 00205 const_preorder_iterator end() const; 00206 }; 00207 00208 00210 00212 00213 template <class T> 00214 tree<T>::tree() { 00215 isempty = true; 00216 parent=NULL; 00217 first=NULL; last=NULL; 00218 prev=NULL; next=NULL; 00219 } 00220 00221 00223 00224 template <class T> 00225 tree<T>::tree(const T &x) : info(x) { 00226 isempty = false; 00227 parent=NULL; 00228 first=NULL; last=NULL; 00229 prev=NULL; next=NULL; 00230 } 00231 00233 00234 template <class T> 00235 tree<T>::tree(const typename tree<T>::preorder_iterator &p) { 00236 clone(*p); 00237 } 00238 00240 00241 template <class T> 00242 tree<T>::tree(const tree<T>& t) { 00243 clone(t); 00244 } 00245 00246 00248 00249 template <class T> 00250 tree<T>& tree<T>::operator=(const tree<T>& t) { 00251 if (this != &t) { 00252 clear(); 00253 clone(t); 00254 } 00255 return (*this); 00256 } 00257 00259 00260 template <class T> 00261 tree<T>::~tree() { 00262 tree *p=this->first; 00263 while (p!=NULL) { 00264 tree *q=p->next; 00265 delete p; 00266 p=q; 00267 } 00268 } 00269 00270 template <class T> 00271 void tree<T>::clear() { 00272 00273 // delete children 00274 tree *p=this->first; 00275 while (p!=NULL) { 00276 tree *q=p->next; 00277 delete p; 00278 p=q; 00279 } 00280 00281 // reset root node 00282 isempty = true; 00283 parent=NULL; 00284 first=NULL; last=NULL; 00285 prev=NULL; next=NULL; 00286 00287 } 00288 00290 00291 template <class T> 00292 unsigned int tree<T>::num_children() const { 00293 tree *s; 00294 unsigned int n=0; 00295 for (s=this->first; s!=NULL; s=s->next) n++; 00296 return n; 00297 } 00298 00300 00301 template <class T> 00302 typename tree<T>::iterator tree<T>::get_parent() const { 00303 iterator i = this->parent; 00304 return i; 00305 } 00306 00308 00309 template <class T> 00310 typename tree<T>::sibling_iterator tree<T>::nth_child(unsigned int n) const { 00311 sibling_iterator i = this->first; 00312 while (n>0 && i!=NULL) { 00313 i = i->next; 00314 n--; 00315 } 00316 return i; 00317 } 00318 00319 00321 00322 template <class T> 00323 tree<T> & tree<T>::nth_child_ref(unsigned int n) const { 00324 sibling_iterator i = this->first; 00325 while (n>0) { 00326 i = i->next; 00327 n--; 00328 } 00329 return (*i); 00330 } 00331 00333 00334 template <class T> 00335 T& tree<T>::get_info() { 00336 return info; 00337 } 00338 00339 00341 00342 template <class T> 00343 bool tree<T>::empty() const { 00344 return isempty; 00345 } 00346 00348 00349 template <class T> 00350 typename tree<T>::sibling_iterator tree<T>::sibling_begin() { 00351 return ::sibling_iterator<T>(this->first); 00352 } 00353 00354 template <class T> 00355 typename tree<T>::const_sibling_iterator tree<T>::sibling_begin() const { 00356 return ::const_sibling_iterator<T>(this->first); 00357 } 00358 00359 template <class T> 00360 typename tree<T>::sibling_iterator tree<T>::sibling_end() { 00361 return ::sibling_iterator<T>(NULL); 00362 } 00363 00364 template <class T> 00365 typename tree<T>::const_sibling_iterator tree<T>::sibling_end() const { 00366 return ::const_sibling_iterator<T>(NULL); 00367 } 00368 00369 00371 00372 template <class T> 00373 typename tree<T>::preorder_iterator tree<T>::begin() { 00374 if (isempty) return ::preorder_iterator<T>(NULL); 00375 else return ::preorder_iterator<T>(this); 00376 } 00377 00378 template <class T> 00379 typename tree<T>::const_preorder_iterator tree<T>::begin() const { 00380 if (isempty) return ::const_preorder_iterator<T>((const tree<T>*)NULL); 00381 else return ::const_preorder_iterator<T>(this); 00382 } 00383 00384 template <class T> 00385 typename tree<T>::preorder_iterator tree<T>::end() { 00386 return ::preorder_iterator<T>((tree<T>*)NULL); 00387 } 00388 00389 template <class T> 00390 typename tree<T>::const_preorder_iterator tree<T>::end() const { 00391 return ::const_preorder_iterator<T>((const tree<T>*)NULL); 00392 } 00393 00394 template <class T> 00395 typename tree<T>::sibling_iterator tree<T>::sibling_rbegin() { 00396 return ::sibling_iterator<T>(this->last); 00397 } 00398 00399 template <class T> 00400 typename tree<T>::const_sibling_iterator tree<T>::sibling_rbegin() const { 00401 return ::const_sibling_iterator<T>(this->last); 00402 } 00403 00404 template <class T> 00405 typename tree<T>::sibling_iterator tree<T>::sibling_rend() { 00406 return ::sibling_iterator<T>(NULL); 00407 } 00408 00409 template <class T> 00410 typename tree<T>::const_sibling_iterator tree<T>::sibling_rend() const { 00411 return ::const_sibling_iterator<T>(NULL); 00412 } 00413 00414 00416 00417 template <class T> 00418 void tree<T>::append_child(const tree<T>& child) { 00419 00420 // make a copy 00421 tree<T> *x = new tree<T>; 00422 x->clone(child); 00423 00424 x->next = NULL; x->prev = NULL; 00425 x->parent = this; 00426 00427 if (this->first != NULL) { // there are already children, join them 00428 x->prev = this->last; 00429 this->last->next = x; 00430 this->last = x; 00431 } 00432 else { 00433 // no children, new is the only one 00434 this->first = x; this->last = x; 00435 } 00436 } 00437 00439 00440 template <class T> 00441 void tree<T>::hang_child(tree<T>& child, bool last) { 00442 00443 // remove child from its current location: 00444 // 1- remove it from siblings chain 00445 if (child.prev) child.prev->next=child.next; 00446 if (child.next) child.next->prev=child.prev; 00447 // 2- adujst parent pointers if first or last child 00448 if (child.parent) { 00449 if (!child.prev) child.parent->first=child.next; 00450 if (!child.next) child.parent->last=child.prev; 00451 } 00452 00453 // hang child on new location 00454 child.prev=NULL; 00455 child.next=NULL; 00456 child.parent = this; 00457 00458 if (this->first == NULL) { 00459 // there are no children, new is the only one 00460 this->first = &child; 00461 this->last = &child; 00462 } 00463 else { 00464 // already children, join them 00465 if (last) { 00466 // append new node as last child 00467 child.prev = this->last; 00468 this->last->next = &child; 00469 this->last = &child; 00470 } 00471 else { 00472 // append new node as first child 00473 child.next = this->first; 00474 this->first->prev = &child; 00475 this->first = &child; 00476 } 00477 } 00478 } 00479 00481 00482 template <class T> 00483 void tree<T>::clone(const tree<T>& t) { 00484 00485 this->isempty = t.isempty; 00486 this->info = t.info; 00487 this->parent = NULL; 00488 this->first = NULL; 00489 this->last = NULL; 00490 this->prev=NULL; 00491 this->next=NULL; 00492 00493 for (tree* p=t.first; p!=NULL; p=p->next) { 00494 00495 tree<T>* c = new tree<T>; 00496 c->clone(*p); 00497 c->next = NULL; 00498 c->prev = NULL; 00499 c->parent = this; 00500 00501 if (this->first != NULL) { 00502 c->prev = this->last; 00503 this->last->next = c; 00504 this->last = c; 00505 } 00506 else { 00507 this->first = c; 00508 this->last = c; 00509 } 00510 } 00511 } 00512 00513 00515 template <class T, class N> 00516 tree_iterator<T,N>::tree_iterator() {pnode = NULL;} 00517 00518 template <class T, class N> 00519 tree_iterator<T,N>::tree_iterator(tree<T> *t) {pnode = t;} 00520 00521 template <class T, class N> 00522 tree_iterator<T,N>::tree_iterator(const tree_iterator<T,N> &o) : pnode(o.pnode) {} 00523 00524 template <class T, class N> 00525 tree_iterator<T,N>::~tree_iterator() {} 00526 00527 template <class T, class N> 00528 const tree<T>& tree_iterator<T,N>::operator*() const {return (*pnode);} 00529 00530 template <class T, class N> 00531 const tree<T>* tree_iterator<T,N>::operator->() const {return pnode;} 00532 00533 template <class T, class N> 00534 bool tree_iterator<T,N>::operator==(const tree_iterator<T,N> &t) const { 00535 return (t.pnode==pnode); 00536 } 00537 00538 template <class T, class N> 00539 bool tree_iterator<T,N>::operator!=(const tree_iterator<T,N> &t) const { 00540 return (t.pnode!=pnode); 00541 } 00542 00544 00545 template <class T> 00546 generic_iterator<T>::generic_iterator() : tree_iterator<T,tree<T> >() {} 00547 00548 template <class T> 00549 generic_iterator<T>::generic_iterator(const generic_iterator<T> & o) : tree_iterator<T,tree<T> >(o.pnode) {} 00550 00551 template <class T> 00552 generic_iterator<T>::generic_iterator(tree<T> *t) : tree_iterator<T,tree<T> >() {this->pnode=t;} 00553 00554 template <class T> 00555 generic_iterator<T>::~generic_iterator() {} 00556 00557 template <class T> 00558 tree<T>& generic_iterator<T>::operator*() const {return (*this->pnode);} 00559 00560 template <class T> 00561 tree<T>* generic_iterator<T>::operator->() const {return this->pnode;} 00562 00563 00565 00566 template <class T> 00567 generic_const_iterator<T>::generic_const_iterator() : tree_iterator<T,const tree<T> >() {} 00568 00569 template <class T> 00570 generic_const_iterator<T>::generic_const_iterator(const generic_iterator<T> & o) : tree_iterator<T,const tree<T> >(o.pnode) {} 00571 00572 template <class T> 00573 generic_const_iterator<T>::generic_const_iterator(const generic_const_iterator<T> & o) : tree_iterator<T,const tree<T> >() {this->pnode=o.pnode;} 00574 00575 template <class T> 00576 generic_const_iterator<T>::generic_const_iterator(tree<T> *t) : tree_iterator<T,const tree<T> >(t) {} 00577 00578 template <class T> 00579 generic_const_iterator<T>::generic_const_iterator(const tree<T> *t) : tree_iterator<T,const tree<T> >() {this->pnode=t;} 00580 00581 template <class T> 00582 generic_const_iterator<T>::~generic_const_iterator() {} 00583 00584 00585 00586 00587 00589 00590 template <class T> 00591 preorder_iterator<T>::preorder_iterator() : generic_iterator<T>() {} 00592 00593 template <class T> 00594 preorder_iterator<T>::preorder_iterator(const preorder_iterator<T> & o) : generic_iterator<T>(o) {} 00595 00596 template <class T> 00597 preorder_iterator<T>::preorder_iterator(const sibling_iterator<T> & o) : generic_iterator<T>(o) {} 00598 00599 template <class T> 00600 preorder_iterator<T>::preorder_iterator(tree<T> *t) : generic_iterator<T>(t) {} 00601 00602 template <class T> 00603 preorder_iterator<T>::~preorder_iterator() {} 00604 00605 00606 00607 template <class T> 00608 preorder_iterator<T>& preorder_iterator<T>::operator++() { 00609 if (this->pnode->first != NULL) 00610 this->pnode=this->pnode->first; 00611 else { 00612 while (this->pnode!=NULL && this->pnode->next==NULL) 00613 this->pnode=this->pnode->parent; 00614 if (this->pnode!=NULL) this->pnode=this->pnode->next; 00615 } 00616 return *this; 00617 } 00618 00619 template <class T> 00620 preorder_iterator<T>& preorder_iterator<T>::operator--() { 00621 if (this->pnode->prev!=NULL) { 00622 this->pnode=this->pnode->prev; 00623 while (this->pnode->last != NULL) 00624 this->pnode=this->pnode->last; 00625 } 00626 else 00627 this->pnode = this->pnode->parent; 00628 00629 return *this; 00630 } 00631 00632 template <class T> 00633 preorder_iterator<T> preorder_iterator<T>::operator++(int) { 00634 preorder_iterator b=(*this); 00635 ++(*this); 00636 return b; 00637 } 00638 00639 template <class T> 00640 preorder_iterator<T> preorder_iterator<T>::operator--(int) { 00641 preorder_iterator b=(*this); 00642 --(*this); 00643 return b; 00644 } 00645 00646 00648 00649 template <class T> 00650 const_preorder_iterator<T>::const_preorder_iterator() : generic_const_iterator<T>() {} 00651 00652 template <class T> 00653 const_preorder_iterator<T>::const_preorder_iterator(const preorder_iterator<T> & o) : generic_const_iterator<T>(o) {} 00654 00655 template <class T> 00656 const_preorder_iterator<T>::const_preorder_iterator(const sibling_iterator<T> & o) : generic_const_iterator<T>(o) {} 00657 00658 template <class T> 00659 const_preorder_iterator<T>::const_preorder_iterator(const const_preorder_iterator<T> & o) : generic_const_iterator<T>(o) {} 00660 00661 template <class T> 00662 const_preorder_iterator<T>::const_preorder_iterator(const const_sibling_iterator<T> & o) : generic_const_iterator<T>(o) {} 00663 00664 template <class T> 00665 const_preorder_iterator<T>::~const_preorder_iterator() {} 00666 00667 template <class T> 00668 const_preorder_iterator<T>::const_preorder_iterator(tree<T> *t) : generic_const_iterator<T>(t) {} 00669 00670 template <class T> 00671 const_preorder_iterator<T>::const_preorder_iterator(const tree<T> *t) : generic_const_iterator<T>(t) {} 00672 00673 template <class T> 00674 const_preorder_iterator<T>& const_preorder_iterator<T>::operator++() { 00675 if (this->pnode->first != NULL) 00676 this->pnode=this->pnode->first; 00677 else { 00678 while (this->pnode!=NULL && this->pnode->next==NULL) 00679 this->pnode=this->pnode->parent; 00680 if (this->pnode!=NULL) this->pnode=this->pnode->next; 00681 } 00682 return *this; 00683 } 00684 00685 template <class T> 00686 const_preorder_iterator<T>& const_preorder_iterator<T>::operator--() { 00687 if (this->pnode->prev!=NULL) { 00688 this->pnode=this->pnode->prev; 00689 while (this->pnode->last != NULL) 00690 this->pnode=this->pnode->last; 00691 } 00692 else 00693 this->pnode = this->pnode->parent; 00694 00695 return *this; 00696 } 00697 00698 template <class T> 00699 const_preorder_iterator<T> const_preorder_iterator<T>::operator++(int) { 00700 const_preorder_iterator b=(*this); 00701 ++(*this); 00702 return b; 00703 } 00704 00705 template <class T> 00706 const_preorder_iterator<T> const_preorder_iterator<T>::operator--(int) { 00707 const_preorder_iterator b=(*this); 00708 --(*this); 00709 return b; 00710 } 00711 00712 00713 /* 00714 template <class T> 00715 const_preorder_iterator<T>& const_preorder_iterator<T>::operator+=(unsigned int n) { 00716 for (; n>0; n--) ++(*this); 00717 return *this; 00718 } 00719 00720 template <class T> 00721 const_preorder_iterator<T>& const_preorder_iterator<T>::operator-=(unsigned int n) { 00722 for (; n>0; n--) --(*this); 00723 return *this; 00724 } 00725 */ 00726 00728 00729 template <class T> 00730 sibling_iterator<T>::sibling_iterator() : generic_iterator<T>() {} 00731 00732 template <class T> 00733 sibling_iterator<T>::sibling_iterator(const sibling_iterator<T> & o) : generic_iterator<T>(o) {} 00734 00735 template <class T> 00736 sibling_iterator<T>::sibling_iterator(tree<T> *t) : generic_iterator<T>(t) {} 00737 00738 template <class T> 00739 sibling_iterator<T>::~sibling_iterator() {} 00740 00741 template <class T> 00742 sibling_iterator<T>& sibling_iterator<T>::operator++() { 00743 this->pnode = this->pnode->next; 00744 return *this; 00745 } 00746 00747 template <class T> 00748 sibling_iterator<T>& sibling_iterator<T>::operator--() { 00749 this->pnode = this->pnode->prev; 00750 return *this; 00751 } 00752 00753 00754 template <class T> 00755 sibling_iterator<T> sibling_iterator<T>::operator++(int) { 00756 sibling_iterator b=(*this); 00757 ++(*this); 00758 return b; 00759 } 00760 00761 template <class T> 00762 sibling_iterator<T> sibling_iterator<T>::operator--(int) { 00763 sibling_iterator b=(*this); 00764 --(*this); 00765 return b; 00766 } 00767 00768 /*template <class T> 00769 sibling_iterator<T>& sibling_iterator<T>::operator+=(unsigned int n) { 00770 for (; n>0; n--) ++(*this); 00771 return *this; 00772 } 00773 00774 template <class T> 00775 sibling_iterator<T>& sibling_iterator<T>::operator-=(unsigned int n) { 00776 for (; n>0; n--) --(*this); 00777 return *this; 00778 } 00779 */ 00780 00782 00783 template <class T> 00784 const_sibling_iterator<T>::const_sibling_iterator() : generic_const_iterator<T>() {} 00785 00786 template <class T> 00787 const_sibling_iterator<T>::const_sibling_iterator(const sibling_iterator<T> & o) : generic_const_iterator<T>(o) {} 00788 00789 template <class T> 00790 const_sibling_iterator<T>::const_sibling_iterator(const const_sibling_iterator<T> & o) : generic_const_iterator<T>(o) {} 00791 00792 template <class T> 00793 const_sibling_iterator<T>::const_sibling_iterator(tree<T> *t) : generic_const_iterator<T>(t) {} 00794 00795 template <class T> 00796 const_sibling_iterator<T>::~const_sibling_iterator() {} 00797 00798 00799 template <class T> 00800 const_sibling_iterator<T>& const_sibling_iterator<T>::operator++() { 00801 this->pnode = this->pnode->next; 00802 return *this; 00803 } 00804 00805 template <class T> 00806 const_sibling_iterator<T>& const_sibling_iterator<T>::operator--() { 00807 this->pnode = this->pnode->prev; 00808 return *this; 00809 } 00810 00811 00812 template <class T> 00813 const_sibling_iterator<T> const_sibling_iterator<T>::operator++(int) { 00814 const_sibling_iterator b=(*this); 00815 ++(*this); 00816 return b; 00817 } 00818 00819 template <class T> 00820 const_sibling_iterator<T> const_sibling_iterator<T>::operator--(int) { 00821 const_sibling_iterator b=(*this); 00822 --(*this); 00823 return b; 00824 } 00825 00826 #endif 00827
1.7.6.1