亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tree.hh

?? 一個德國人Kasper Peeters用C++ template寫的tree的STL實現
?? HH
?? 第 1 頁 / 共 5 頁
字號:
/*    $Id: tree.hh,v 1.125 2006/01/31 17:44:43 kp229 Exp $   STL-like templated tree class.   Copyright (C) 2001-2006  Kasper Peeters <kasper.peeters@aei.mpg.de>.*//** \mainpage tree.hh    \author   Kasper Peeters    \version  2.03    \date     01-Mar-2006    \see      http://www.aei.mpg.de/~peekas/tree/    \see      http://www.aei.mpg.de/~peekas/tree/ChangeLog   The tree.hh library for C++ provides an STL-like container class   for n-ary trees, templated over the data stored at the   nodes. Various types of iterators are provided (post-order,   pre-order, and others). Where possible the access methods are   compatible with the STL or alternative algorithms are   available. *//*   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; version 2.      This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.      You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*//** \todo    - New-style move members are not completely finished yet.   - Fixed depth iterators do not iterate over the entire range if there     are 'holes' in the tree.   - If a range uses const iter_base& as end iterator, things will     inevitably go wrong, because upcast from iter_base to a non-sibling_iter     is incorrect. This upcast should be removed (and then all illegal uses     as previously in 'equal' will be flagged by the compiler). This requires     new copy constructors though.   - There's a bug in replace(sibling_iterator, ...) when the ranges     sit next to each other. Turned up in append_child(iter,iter)     but has been avoided now.   - "std::operator<" does not work correctly on our iterators, and for some     reason a globally defined template operator< did not get picked up.      Using a comparison class now, but this should be investigated.*/#ifndef tree_hh_#define tree_hh_#include <cassert>#include <memory>#include <stdexcept>#include <iterator>#include <set>#include <queue>// HP-style construct/destroy have gone from the standard,// so here is a copy.namespace kp {template <class T1, class T2>void constructor(T1* p, T2& val)    {   new ((void *) p) T1(val);   }template <class T1>void constructor(T1* p)    {   new ((void *) p) T1;   }template <class T1>void destructor(T1* p)   {   p->~T1();   }};/// A node in the tree, combining links to other nodes as well as the actual data.template<class T>class tree_node_ { // size: 5*4=20 bytes (on 32 bit arch), can be reduced by 8.   public:      tree_node_<T> *parent;      tree_node_<T> *first_child, *last_child;      tree_node_<T> *prev_sibling, *next_sibling;      T data;}; // __attribute__((packed));template <class T, class tree_node_allocator = std::allocator<tree_node_<T> > >class tree {   protected:      typedef tree_node_<T> tree_node;   public:      /// Value of the data stored at a node.      typedef T value_type;      class iterator_base;      class pre_order_iterator;      class post_order_iterator;      class sibling_iterator;      tree();      tree(const T&);      tree(const iterator_base&);      tree(const tree<T, tree_node_allocator>&);      ~tree();      void operator=(const tree<T, tree_node_allocator>&);      /// Base class for iterators, only pointers stored, no traversal logic.#ifdef __SGI_STL_PORT      class iterator_base : public stlport::bidirectional_iterator<T, ptrdiff_t> {#else      class iterator_base {#endif         public:            typedef T                               value_type;            typedef T*                              pointer;            typedef T&                              reference;            typedef size_t                          size_type;            typedef ptrdiff_t                       difference_type;            typedef std::bidirectional_iterator_tag iterator_category;            iterator_base();            iterator_base(tree_node *);            T&             operator*() const;            T*             operator->() const;            /// When called, the next increment/decrement skips children of this node.            void         skip_children();            /// Number of children of the node pointed to by the iterator.            unsigned int number_of_children() const;            sibling_iterator begin() const;            sibling_iterator end() const;            tree_node *node;         protected:            bool skip_current_children_;      };      /// Depth-first iterator, first accessing the node, then its children.      class pre_order_iterator : public iterator_base {          public:            pre_order_iterator();            pre_order_iterator(tree_node *);            pre_order_iterator(const iterator_base&);            pre_order_iterator(const sibling_iterator&);            bool    operator==(const pre_order_iterator&) const;            bool    operator!=(const pre_order_iterator&) const;            pre_order_iterator&  operator++();            pre_order_iterator&  operator--();            pre_order_iterator   operator++(int);            pre_order_iterator   operator--(int);            pre_order_iterator&  operator+=(unsigned int);            pre_order_iterator&  operator-=(unsigned int);      };      /// Depth-first iterator, first accessing the children, then the node itself.      class post_order_iterator : public iterator_base {         public:            post_order_iterator();            post_order_iterator(tree_node *);            post_order_iterator(const iterator_base&);            post_order_iterator(const sibling_iterator&);            bool    operator==(const post_order_iterator&) const;            bool    operator!=(const post_order_iterator&) const;            post_order_iterator&  operator++();            post_order_iterator&  operator--();            post_order_iterator   operator++(int);            post_order_iterator   operator--(int);            post_order_iterator&  operator+=(unsigned int);            post_order_iterator&  operator-=(unsigned int);            /// Set iterator to the first child as deep as possible down the tree.            void descend_all();      };      /// Breadth-first iterator, using a queue      class breadth_first_queued_iterator : public iterator_base {         public:            breadth_first_queued_iterator();            breadth_first_queued_iterator(tree_node *);            breadth_first_queued_iterator(const iterator_base&);            bool    operator==(const breadth_first_queued_iterator&) const;            bool    operator!=(const breadth_first_queued_iterator&) const;            breadth_first_queued_iterator&  operator++();            breadth_first_queued_iterator   operator++(int);            breadth_first_queued_iterator&  operator+=(unsigned int);         private:            std::queue<tree_node *> traversal_queue;      };      /// The default iterator types throughout the tree class.      typedef pre_order_iterator            iterator;      typedef breadth_first_queued_iterator breadth_first_iterator;      /// Iterator which traverses only the nodes at a given depth from the root.      class fixed_depth_iterator : public iterator_base {         public:            fixed_depth_iterator();            fixed_depth_iterator(tree_node *);            fixed_depth_iterator(const iterator_base&);            fixed_depth_iterator(const sibling_iterator&);            fixed_depth_iterator(const fixed_depth_iterator&);            bool    operator==(const fixed_depth_iterator&) const;            bool    operator!=(const fixed_depth_iterator&) const;            fixed_depth_iterator&  operator++();            fixed_depth_iterator&  operator--();            fixed_depth_iterator   operator++(int);            fixed_depth_iterator   operator--(int);            fixed_depth_iterator&  operator+=(unsigned int);            fixed_depth_iterator&  operator-=(unsigned int);            tree_node *first_parent_;         private:            void set_first_parent_();            void find_leftmost_parent_();      };      /// Iterator which traverses only the nodes which are siblings of each other.      class sibling_iterator : public iterator_base {         public:            sibling_iterator();            sibling_iterator(tree_node *);            sibling_iterator(const sibling_iterator&);            sibling_iterator(const iterator_base&);            bool    operator==(const sibling_iterator&) const;            bool    operator!=(const sibling_iterator&) const;            sibling_iterator&  operator++();            sibling_iterator&  operator--();            sibling_iterator   operator++(int);            sibling_iterator   operator--(int);            sibling_iterator&  operator+=(unsigned int);            sibling_iterator&  operator-=(unsigned int);            tree_node *range_first() const;            tree_node *range_last() const;            tree_node *parent_;         private:            void set_parent_();      };      /// Return iterator to the beginning of the tree.      inline pre_order_iterator   begin() const;      /// Return iterator to the end of the tree.      inline pre_order_iterator   end() const;      /// Return post-order iterator to the beginning of the tree.      post_order_iterator  begin_post() const;      /// Return post-order iterator to the end of the tree.      post_order_iterator  end_post() const;      /// Return fixed-depth iterator to the first node at a given depth.      fixed_depth_iterator begin_fixed(const iterator_base&, unsigned int) const;      /// Return fixed-depth iterator to end of the nodes at given depth.      fixed_depth_iterator end_fixed(const iterator_base&, unsigned int) const;      /// Return breadth-first iterator to the first node at a given depth.      breadth_first_queued_iterator begin_breadth_first() const;      /// Return breadth-first iterator to end of the nodes at given depth.      breadth_first_queued_iterator end_breadth_first() const;      /// Return sibling iterator to the first child of given node.      sibling_iterator     begin(const iterator_base&) const;      /// Return sibling iterator to the end of the children of a given node.      sibling_iterator     end(const iterator_base&) const;      /// Return iterator to the parent of a node.      template<typename iter> iter parent(iter) const;      /// Return iterator to the previous sibling of a node.      template<typename iter> iter previous_sibling(iter) const;      /// Return iterator to the next sibling of a node.      template<typename iter> iter next_sibling(iter) const;      /// Return iterator to the next node at a given depth.      template<typename iter> iter next_at_same_depth(iter) const;      /// Erase all nodes of the tree.      void     clear();      /// Erase element at position pointed to by iterator, return incremented iterator.      template<typename iter> iter erase(iter);      /// Erase all children of the node pointed to by iterator.      void     erase_children(const iterator_base&);      /// Insert empty node as last child of node pointed to by position.      template<typename iter> iter append_child(iter position);       /// Insert node as last child of node pointed to by position.      template<typename iter> iter append_child(iter position, const T& x);      /// Append the node (plus its children) at other_position as a child of position.      template<typename iter> iter append_child(iter position, iter other_position);      /// Append the nodes in the from-to range (plus their children) as children of position.      template<typename iter> iter append_children(iter position, sibling_iterator from, sibling_iterator to);      /// Short-hand to insert topmost node in otherwise empty tree.      pre_order_iterator set_head(const T& x);      /// Insert node as previous sibling of node pointed to by position.      template<typename iter> iter insert(iter position, const T& x);      /// Specialisation of previous member.      sibling_iterator insert(sibling_iterator position, const T& x);      /// Insert node (with children) pointed to by subtree as previous sibling of node pointed to by position.      template<typename iter> iter insert_subtree(iter position, const iterator_base& subtree);      /// Insert node as next sibling of node pointed to by position.      template<typename iter> iter insert_after(iter position, const T& x);      /// Replace node at 'position' with other node (keeping same children); 'position' becomes invalid.      template<typename iter> iter replace(iter position, const T& x);      /// Replace node at 'position' with subtree starting at 'from' (do not erase subtree at 'from'); see above.      template<typename iter> iter replace(iter position, const iterator_base& from);      /// Replace string of siblings (plus their children) with copy of a new string (with children); see above      sibling_iterator replace(sibling_iterator orig_begin, sibling_iterator orig_end,                                sibling_iterator new_begin,  sibling_iterator new_end);       /// Move all children of node at 'position' to be siblings, returns position.      template<typename iter> iter flatten(iter position);      /// Move nodes in range to be children of 'position'.      template<typename iter> iter reparent(iter position, sibling_iterator begin, sibling_iterator end);      /// Move all child nodes of 'from' to be children of 'position'.      template<typename iter> iter reparent(iter position, iter from);      /// Move 'source' node (plus its children) to become the next sibling of 'target'.      template<typename iter> iter move_after(iter target, iter source);      /// Move 'source' node (plus its children) to become the previous sibling of 'target'.      template<typename iter> iter move_before(iter target, iter source);      sibling_iterator move_before(sibling_iterator target, sibling_iterator source);      /// Move 'source' node (plus its children) to become the node at 'target' (erasing the node at 'target').      template<typename iter> iter move_ontop(iter target, iter source);      /// Merge with other tree, creating new branches and leaves only if they are not already present.      void     merge(sibling_iterator, sibling_iterator, sibling_iterator, sibling_iterator,                      bool duplicate_leaves=false);      /// Sort (std::sort only moves values of nodes, this one moves children as well).      void     sort(sibling_iterator from, sibling_iterator to, bool deep=false);      template<class StrictWeakOrdering>      void     sort(sibling_iterator from, sibling_iterator to, StrictWeakOrdering comp, bool deep=false);      /// Compare two ranges of nodes (compares nodes as well as tree structure).      template<typename iter>      bool     equal(const iter& one, const iter& two, const iter& three) const;      template<typename iter, class BinaryPredicate>      bool     equal(const iter& one, const iter& two, const iter& three, BinaryPredicate) const;      template<typename iter>      bool     equal_subtree(const iter& one, const iter& two) const;      template<typename iter, class BinaryPredicate>      bool     equal_subtree(const iter& one, const iter& two, BinaryPredicate) const;      /// Extract a new tree formed by the range of siblings plus all their children.      tree     subtree(sibling_iterator from, sibling_iterator to) const;      void     subtree(tree&, sibling_iterator from, sibling_iterator to) const;      /// Exchange the node (plus subtree) with its sibling node (do nothing if no sibling present).      void     swap(sibling_iterator it);            /// Count the total number of nodes.      int      size() const;      /// Check if tree is empty.      bool     empty() const;      /// Compute the depth to the root.      int      depth(const iterator_base&) const;      /// Count the number of children of node at position.      static unsigned int number_of_children(const iterator_base&);      /// Count the number of 'next' siblings of node at iterator.      unsigned int number_of_siblings(const iterator_base&) const;      /// Determine whether node at position is in the subtrees with root in the range.      bool     is_in_subtree(const iterator_base& position, const iterator_base& begin,                              const iterator_base& end) const;      /// Determine whether the iterator is an 'end' iterator and thus not actually pointing to a node.      bool     is_valid(const iterator_base&) const;      /// Determine the index of a node in the range of siblings to which it belongs.      unsigned int index(sibling_iterator it) const;      /// Inverse of 'index': return the n-th child of the node at position.      sibling_iterator  child(const iterator_base& position, unsigned int) const;            /// Comparator class for iterators (compares pointer values; why doesn't this work automatically?)      class iterator_base_less {         public:            bool operator()(const typename tree<T, tree_node_allocator>::iterator_base& one,                            const typename tree<T, tree_node_allocator>::iterator_base& two) const               {               return one.node < two.node;               }      };      tree_node *head, *feet;    // head/feet are always dummy; if an iterator points to them it is invalid   private:      tree_node_allocator alloc_;      void head_initialise_();      void copy_(const tree<T, tree_node_allocator>& other);      /// Comparator class for two nodes of a tree (used for sorting and searching).

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品区一区二区| av影院午夜一区| 欧美日韩大陆在线| 亚洲一区二区中文在线| 欧美日韩国产bt| 亚洲成av人**亚洲成av**| 欧美老女人在线| 捆绑调教美女网站视频一区| 欧美一区三区四区| 国产麻豆一精品一av一免费| 久久综合九色综合欧美98 | 91国产丝袜在线播放| 中文字幕亚洲一区二区va在线| 成人精品国产福利| 一区二区久久久久| 在线播放一区二区三区| 韩国在线一区二区| 中文字幕欧美三区| 欧美在线看片a免费观看| 亚洲电影视频在线| 精品国产伦一区二区三区观看体验| 日本不卡123| 久久久久国产精品厨房| 99久久精品国产一区二区三区 | 欧美激情一区二区在线| 91免费在线视频观看| 丝袜国产日韩另类美女| 久久尤物电影视频在线观看| 成人黄色在线网站| 亚洲国产精品视频| 久久综合久久综合久久综合| 99国产精品久久久久久久久久| 亚洲国产日韩精品| 国产偷v国产偷v亚洲高清| 色94色欧美sute亚洲线路一久| 五月婷婷欧美视频| 国产欧美精品国产国产专区| 在线精品国精品国产尤物884a| 久久电影网站中文字幕| 一区二区在线免费观看| 国产日产欧美精品一区二区三区| 欧美日韩五月天| 国产成人在线影院| 偷拍一区二区三区| 中文字幕一区二区三区四区不卡| 91精品国产91综合久久蜜臀| aaa国产一区| 蜜臀av性久久久久蜜臀av麻豆| 国产精品久久久久三级| 精品久久一区二区三区| 在线观看日产精品| 成人午夜私人影院| 狠狠色丁香婷婷综合| 亚洲成人av免费| 国产精品三级电影| 久久精品夜夜夜夜久久| 日韩一区和二区| 在线观看中文字幕不卡| 91香蕉国产在线观看软件| 国产精品亚洲专一区二区三区| 午夜视频在线观看一区二区三区| 国产精品美女一区二区在线观看| 日韩欧美国产一区二区三区| 欧美午夜电影在线播放| 国产成人福利片| 国内欧美视频一区二区 | 捆绑变态av一区二区三区| 一区二区三区精品| **欧美大码日韩| 国产精品午夜春色av| 久久久欧美精品sm网站| 337p日本欧洲亚洲大胆精品| 欧美一级一区二区| 欧美精品在线观看播放| 欧美特级限制片免费在线观看| 97精品久久久午夜一区二区三区 | 午夜久久久影院| 一区二区日韩av| 亚洲理论在线观看| 亚洲美腿欧美偷拍| 国产精品白丝在线| 中文字幕一区三区| 中文字幕在线一区二区三区| 国产精品福利电影一区二区三区四区 | 久久精品水蜜桃av综合天堂| 精品欧美乱码久久久久久 | 亚洲综合一区在线| 亚洲精品视频自拍| 51精品视频一区二区三区| 久久婷婷色综合| 国产九色精品成人porny| 美女视频网站久久| 久色婷婷小香蕉久久| 九九视频精品免费| 亚洲精品日产精品乱码不卡| 一区二区三区中文字幕精品精品| 乱一区二区av| 欧美日韩中文国产| 中文字幕久久午夜不卡| 奇米色一区二区| 一本到三区不卡视频| 精品国产乱码久久久久久蜜臀 | 久久亚洲精品小早川怜子| 一个色妞综合视频在线观看| 国产麻豆成人精品| 日韩一区二区视频| 一区2区3区在线看| 成人国产免费视频| 精品国产一区二区在线观看| 亚洲午夜视频在线| 99精品久久免费看蜜臀剧情介绍| 亚洲精品一区二区三区在线观看| 亚洲电影视频在线| 91久久精品一区二区三| 国产精品国产三级国产| 国产激情91久久精品导航| 日韩欧美中文字幕精品| 亚洲国产精品影院| 在线免费一区三区| 亚洲乱码中文字幕| av福利精品导航| 国产蜜臀97一区二区三区| 精东粉嫩av免费一区二区三区| 正在播放亚洲一区| 午夜国产精品影院在线观看| 欧美性三三影院| 一区二区三区四区视频精品免费 | 国产日产欧美一区二区三区| 久久精品国产999大香线蕉| 欧美色老头old∨ideo| 亚洲欧美日韩综合aⅴ视频| 91在线视频官网| 中文字幕亚洲综合久久菠萝蜜| 成人美女视频在线观看| 久久精品亚洲精品国产欧美kt∨ | 国产精品一卡二卡| 精品国产91久久久久久久妲己| 青青草成人在线观看| 日韩视频免费观看高清完整版在线观看 | 日韩一级免费观看| 日本美女一区二区三区| 宅男在线国产精品| 日本不卡高清视频| 精品国产3级a| 国产福利不卡视频| 国产精品欧美综合在线| 99视频热这里只有精品免费| 综合欧美一区二区三区| 色诱视频网站一区| 亚洲国产aⅴ天堂久久| 制服.丝袜.亚洲.另类.中文| 蜜桃视频在线一区| 久久久久久**毛片大全| 99久久综合精品| 亚洲一级片在线观看| 3d动漫精品啪啪| 国产一区二区精品在线观看| 国产精品高潮久久久久无| 在线影视一区二区三区| 视频一区二区欧美| 精品久久人人做人人爰| 成人动漫av在线| 亚洲最色的网站| 日韩一区二区三区电影在线观看 | 精东粉嫩av免费一区二区三区| 欧美国产一区二区在线观看| 99精品欧美一区| 午夜精品一区二区三区电影天堂| 欧美大片在线观看| 丁香另类激情小说| 亚洲一区二区三区四区在线 | 日韩成人午夜电影| 久久久久国色av免费看影院| 91蝌蚪porny| 奇米影视7777精品一区二区| 中文字幕免费不卡在线| 欧美日韩中文字幕一区二区| 国内精品免费**视频| 亚洲精品免费在线观看| 日韩欧美中文字幕精品| 91麻豆6部合集magnet| 麻豆精品视频在线观看视频| 国产精品第四页| 日韩三级伦理片妻子的秘密按摩| 国产suv精品一区二区883| 亚洲尤物在线视频观看| www久久久久| 欧美特级限制片免费在线观看| 国产精品一区一区三区| 亚洲成av人**亚洲成av**| 国产精品情趣视频| 日韩欧美在线网站| 91高清视频免费看| 国产一区二区美女诱惑| 亚洲午夜精品17c| 久久久久久一二三区| 欧美日韩国产系列| 99精品久久免费看蜜臀剧情介绍| 韩国理伦片一区二区三区在线播放 | 国产亚洲一区字幕|