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

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

?? tree.h

?? CAN__組建現場總線系統設計技術(光盤)
?? H
?? 第 1 頁 / 共 3 頁
字號:
					toit=append_child(parent(toit), current_from->data);
				}
			}
		}while(current_from!=last);

		return current_to;
	}

	// replace string of siblings (plus their children) with copy of a new string (with children)
	iterator replace(sibling_iterator orig_begin, sibling_iterator orig_end, 
						  sibling_iterator new_begin,  sibling_iterator new_end){
		tree_node *orig_first=orig_begin.node;
		tree_node *new_first=new_begin.node;
		tree_node *orig_last=orig_first;
		while(++orig_begin!=orig_end)
			orig_last=orig_last->next_sibling;
		tree_node *new_last=new_first;
		while(++new_begin!=new_end)
			new_last=new_last->next_sibling;
		// insert all siblings in new_first..new_last before orig_first
		bool first=true;
		iterator ret;
		while(1==1) {
			iterator tt=insert(iterator(orig_first), new_first);
			if(first) {
				ret=tt;
				first=false;
			}
			if(new_first==new_last)
				break;
			new_first=new_first->next_sibling;
		}
		// erase old range of siblings
		bool last=false;
		tree_node *next=orig_first;
		while(1==1) {
			if(next==orig_last) 
				last=true;
			next=next->next_sibling;
			erase(orig_first);
			if(last) 
				break;
			orig_first=next;
		}
		return ret;
	}
 

	// move all children of node at 'position' to be siblings
	iterator flatten(iterator position)
	{
		if(position.node->first_child==0)
			return position;
		tree_node *tmp=position.node->first_child;
		while(tmp) {
			tmp->parent=position.node->parent;
			tmp=tmp->next_sibling;
		} 
		if(position.node->next_sibling) {
			position.node->last_child->next_sibling=position.node->next_sibling;
			position.node->next_sibling->prev_sibling=position.node->last_child;
		}
		else {
			position.node->parent->last_child=position.node->last_child;
		}
		position.node->next_sibling=position.node->first_child;
		position.node->next_sibling->prev_sibling=position.node;
		position.node->first_child=0;
		position.node->last_child=0;
		return position;
	}

	// move nodes in range to be children of 'position'
	iterator reparent(iterator position, sibling_iterator begin, sibling_iterator end)
	{
		tree_node *first=begin.node;
		tree_node *last=first;
		while(++begin!=end) {
			last=last->next_sibling;
		}
		// move subtree
		if(first->prev_sibling==0) {
			first->parent->first_child=last->next_sibling;
		}
		else {
			first->prev_sibling->next_sibling=last->next_sibling;
		}
		if(last->next_sibling==0) {
			last->parent->last_child=first->prev_sibling;
		}
		else {
			last->next_sibling->prev_sibling=first->prev_sibling;
		}
		if(position.node->first_child==0) {
			position.node->first_child=first;
			position.node->last_child=last;
			first->prev_sibling=0;
		}
		else {
			position.node->last_child->next_sibling=first;
			first->prev_sibling=position.node->last_child;
			position.node->last_child=last;
		}
		last->next_sibling=0;

		tree_node *pos=first;
		while(1==1) {
			pos->parent=position.node;
			if(pos==last) break;
			pos=pos->next_sibling;
		}
		return first;
	}

	// ditto, the range being all children of the 'from' node
	iterator reparent(iterator position, iterator from)
	{
		if(from.node->first_child==0) return position;
		return reparent(position, from.node->first_child, from.node->last_child);
	}

	// merge with other tree, creating new branches and leaves only if they are not already present
	void merge(iterator position, iterator other, bool duplicate_leaves=false)
	{
		sibling_iterator fnd;
		sibling_iterator oit=other;
		while(oit.is_valid()) {
			if((fnd=find(position.begin(), position.end(), (*other)))!=position.end()) {
				if(duplicate_leaves && other.begin()==other.end()) { // it's a leave
					append_child(position, (*other));
				}
				else {
					if(other.begin()!=other.end())
						merge(fnd, other.begin(), duplicate_leaves);
				}
			}
			else {
				insert(position.end(), oit);
			}
			++oit;
		}
	}

	// 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)
	{
		std::less<T> comp;
		sort(from, to, comp, deep);
	}

	template<class StrictWeakOrdering>
	void sort(sibling_iterator from, sibling_iterator to, StrictWeakOrdering comp, bool deep=false)
	{
		if(from==to) return;
		// make list of sorted nodes
		// CHECK: if multiset stores equivalent nodes in the order in which they
		// are inserted, then this routine should be called 'stable_sort'.
		std::multiset<tree_node *, compare_nodes<StrictWeakOrdering> > nodes;
		sibling_iterator it=from, it2=to;
		while(it != to) {
			nodes.insert(it.node);
			++it;
		}
		// reassemble
		--it2;
		tree_node *prev=from.node->prev_sibling;
		tree_node *next=it2.node->next_sibling;
		typename std::multiset<tree_node *, compare_nodes<StrictWeakOrdering> >::iterator nit=nodes.begin(), eit=nodes.end();
		if(prev==0) {
			(*nit)->parent->first_child=(*nit);
		}
		--eit;
		while(nit!=eit) {
			(*nit)->prev_sibling=prev;
			if(prev)
				prev->next_sibling=(*nit);
			prev=(*nit);
			++nit;
		}
		if(prev)
			prev->next_sibling=(*eit);
		(*eit)->next_sibling=next;
		if(next==0) {
			(*eit)->parent->last_child=next;
		}

		if(deep) {	// sort the children of each node too
			sibling_iterator bcs(*nodes.begin());
			sibling_iterator ecs(*eit);
			++ecs;
			while(bcs!=ecs) {
				sort(begin(bcs), end(bcs), comp, deep);
				++bcs;
			}
		}
	}

	// compare subtrees starting at the two iterators (compares nodes as well as tree structure)
	template<class BinaryPredicate>
	bool equal(iterator one, iterator two, iterator three, BinaryPredicate fun) const
	{
		while(one!=two && three.is_valid()) {
			if(one.number_of_children()!=three.number_of_children()) 
				return false;
			if(!fun(*one,*three))
				return false;
			++one;
			++three;
		}
		return true;
	}

	// extract a new tree formed by the range of siblings plus all their children
	tree subtree(sibling_iterator from, sibling_iterator to) const
	{
		tree tmp;
		tmp.set_head(value_type());
		tmp.replace(tmp.begin(), tmp.end(), from, to);
		return tmp;
	}
	void subtree(tree&, sibling_iterator from, sibling_iterator to) const
	{
		tree tmp;
		tmp.set_head(value_type());
		tmp.replace(tmp.begin(), tmp.end(), from, to);
	}
		
	// count the total number of nodes
	//樹中的節點總數
	int size() const{
		int i=0;
		iterator it=begin(), eit=end();
		while(it!=eit) {
			++i;
			++it;
		}
		return i;
	}

	// compute the depth to the root
	// root的深度是0
	int depth(iterator it) const{
		tree_node* pos=it.node;
		assert(pos!=0);//it必須有效
		int dep=0;
		while(pos->parent) {//root的parent是0
			pos=pos->parent;
			++dep;
		}
		return dep;
	}

	// count the number of children of node at position
	//it指向的節點的子節點的總數
	unsigned int number_of_children(iterator it) const{
		tree_node *pos=it.node->first_child;
			//如果it.node == 0,怎么辦?
		if(pos==0) return 0;
			
		unsigned int count=1;
		while(pos!=it.node->last_child) {
			++count;
			pos=pos->next_sibling;
		}
		return count;
	}

	// count the number of 'next' siblings of node at iterator
	//計算 ---"弟"---節點 的個數
	unsigned int number_of_siblings(iterator it) const
	{
		tree_node *pos=it.node;
		unsigned int ret=1;
		while(pos->next_sibling && pos->next_sibling!=head) {
			//兄弟節點是對同一個直接父節點而言的。如果計算的是樹的棵數,則要
			//加判斷 pos->next_sibling!=head
			++ret;
			pos=pos->next_sibling;
		}
		return ret;
	}

	//增加:陳真勇 2002/11/29
	// 尋找一個節點,并指向它
	iterator find(T& data,iterator start)
	{
		iterator it;
		for(it = begin(); it != end(); ++it){
			if( *it == data ) break;
		}

		return it;
	}
	//增加:陳真勇 2002/11/29
	//	是直接子節點嗎?
	bool is_child(iterator parent,iterator child)
	{
		sibling_iterator ch = parent.begin();
		for(;ch != parent.end();++ch){
			if(ch == child)
				return true;
		}
		return false;
	}

	// determine whether node at position is in the subtrees with root in the range
	// 判斷position是否在[begin,end)內
	bool  is_in_subtree(iterator position, iterator begin, iterator end) const
	{
		// FIXME: this should be optimised.
		iterator tmp=begin;
		while(tmp!=end) {
			if(tmp==position) return true;//change from it to position. by zychen
			++tmp;
		}
		return false;
	}

	// return the n-th child of the node at position
	// 返回節點position的第num個子節點數據。第一個對應num==0
	T& child(iterator position, unsigned int num) const{
		tree_node *tmp=position.node->first_child;//change from it to position. by zychen
		while(num--){
			assert(tmp!=0);
			tmp=tmp->next_sibling;
		}
		return tmp->data;
	}
private:
	tree_node_allocator alloc_;
	tree_node *head;    // head is always a dummy; if an iterator points to head it is invalid

	//初始化head節點,不放數據
	void head_initialise_(){
			head = alloc_.allocate(1,0); // MSVC does not have default second argument 
				//1 element,no hint

			head->parent=0;//沒有父節點。這樣一來,所有的樹的根節點的parent都將為0
			head->first_child=0;//沒有子節點
			head->last_child=0;
			head->prev_sibling=head;
			head->next_sibling=head;
	}

	//將other樹拷貝為當前樹
	void copy_(const tree<T,tree_node_allocator>& other){
			clear();//清除當前森林
			iterator it=other.begin(), to=begin();
			while(it!=other.end()){
				to=insert(to, (*it));
				it.skip_children();//為什么不用next_sibling?
				++it;
			}
			to=begin();
			it=other.begin();
			while(it!=other.end()){
				to=replace(to, it);
				to.skip_children();
				it.skip_children();
				++to;
				++it;
			}
	}
	template<class StrictWeakOrdering>
	class compare_nodes
	{
	public:
		bool operator()(const tree_node* a, const tree_node* b){
			static StrictWeakOrdering comp;
			return comp(a->data, b->data);
		}
	};
};

#endif

// Local variables:
// default-tab-width: 3
// End:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩avvvv在线播放| 4438x成人网最大色成网站| 一区二区三区四区乱视频| 精品美女一区二区| 亚洲午夜私人影院| av午夜精品一区二区三区| 久久久91精品国产一区二区三区| 激情都市一区二区| 欧美一区日韩一区| 精品盗摄一区二区三区| 奇米777欧美一区二区| 国产在线一区二区综合免费视频| 在线播放欧美女士性生活| 亚洲在线视频网站| 欧美日韩久久一区| 亚洲一区二区三区三| 欧美日韩精品欧美日韩精品| 亚洲国产精品麻豆| 欧美性一级生活| 欧美日韩国产首页在线观看| 午夜电影久久久| 99国内精品久久| 亚洲欧美日韩一区二区| 久久成人久久爱| 久久婷婷一区二区三区| 懂色av中文字幕一区二区三区| 色国产综合视频| 亚洲国产精品久久不卡毛片| 欧美精品一二三| 理论电影国产精品| 中文字幕av一区二区三区免费看| 国产91露脸合集magnet| 亚洲欧美欧美一区二区三区| 欧美天堂亚洲电影院在线播放| 日韩精品一卡二卡三卡四卡无卡| 日韩午夜激情av| 懂色av中文一区二区三区 | 成人av先锋影音| 亚洲最色的网站| 91精品国产欧美一区二区18| 成人精品视频.| 日日摸夜夜添夜夜添亚洲女人| 久久精子c满五个校花| 91在线视频播放| 男男视频亚洲欧美| 国产欧美一区二区精品性| 欧美羞羞免费网站| 国产精品亚洲午夜一区二区三区| 亚洲精品乱码久久久久久黑人| 欧美妇女性影城| 国产成人a级片| 一区二区三区美女| wwwwxxxxx欧美| 在线观看亚洲精品视频| 国产一区激情在线| 亚洲韩国精品一区| 国产精品全国免费观看高清| 欧美日韩国产电影| 色综合久久中文字幕| 欧美大片免费久久精品三p | 亚洲一级电影视频| 久久综合丝袜日本网| 欧美午夜片在线看| 成人午夜激情影院| 蜜桃视频在线一区| 亚洲色图丝袜美腿| 久久久国产午夜精品| 欧美丰满美乳xxx高潮www| av一区二区三区| 国产一区二区毛片| 五月综合激情日本mⅴ| 国产精品久久久久影院色老大| 欧美一卡在线观看| 一本大道综合伊人精品热热| 麻豆精品久久久| 亚洲国产中文字幕| 亚洲欧洲另类国产综合| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 久久精品免费观看| 亚洲午夜久久久久久久久久久 | 亚洲柠檬福利资源导航| 亚洲精品第一国产综合野| 日韩三级视频中文字幕| 欧美午夜在线观看| 国产成人精品aa毛片| 紧缚奴在线一区二区三区| 亚洲第一激情av| 一卡二卡欧美日韩| 亚洲视频在线一区二区| 国产精品网站在线| 精品电影一区二区| 精品日韩在线一区| 欧美一区二区视频免费观看| 欧美色区777第一页| 日本韩国欧美一区二区三区| 97精品久久久午夜一区二区三区| 国产一区二区三区综合| 日韩vs国产vs欧美| 日韩黄色免费电影| 免费日韩伦理电影| 免费观看日韩av| 日韩综合小视频| 三级久久三级久久| 日韩二区三区四区| 久久精品国产亚洲高清剧情介绍| 青娱乐精品在线视频| 日日噜噜夜夜狠狠视频欧美人| 日韩成人免费在线| 久久99国产精品久久| 激情五月播播久久久精品| 精品一区二区三区香蕉蜜桃 | 精品综合免费视频观看| 国产在线播放一区三区四| 国产精品91xxx| 成人高清视频在线| 91精品1区2区| 在线成人小视频| 精品国内片67194| 91精品国产日韩91久久久久久| 欧美高清激情brazzers| 国产一区啦啦啦在线观看| 亚洲成av人片观看| 免费在线成人网| 激情综合网天天干| 国产成人精品一区二区三区四区| 成人av中文字幕| 91在线一区二区三区| 欧美在线视频日韩| 91精品国产综合久久久久久 | 97久久超碰国产精品| 91国模大尺度私拍在线视频| 日韩久久一区二区| 一区二区三区免费网站| 蜜桃av一区二区在线观看| 国产不卡一区视频| 欧美日韩一区二区不卡| 久久久不卡网国产精品一区| 亚洲卡通欧美制服中文| 日韩国产欧美三级| 国产成人精品免费看| 欧美日韩免费在线视频| 久久久久久99精品| 亚洲第一二三四区| 成人夜色视频网站在线观看| 在线视频欧美精品| 国产女人18毛片水真多成人如厕| 亚洲一区二区三区小说| 国产精品中文字幕日韩精品| 欧美日韩综合一区| 国产精品系列在线| 理论片日本一区| 欧美亚洲国产一卡| 国产欧美一区二区三区沐欲| 日韩高清一区在线| 国产成人av电影在线| 欧美精品在线观看播放| 自拍视频在线观看一区二区| 经典一区二区三区| 欧美日韩色一区| 精品成a人在线观看| 一区二区三区在线视频观看| 国产高清在线观看免费不卡| 欧美电影在线免费观看| 国产蜜臀97一区二区三区| 日韩电影在线观看网站| 成人免费视频一区二区| 色综合天天做天天爱| 国产精品免费久久久久| 国产成人亚洲综合a∨婷婷图片 | 91一区二区在线观看| 国产精品久久夜| 成人黄色国产精品网站大全在线免费观看 | 欧美日韩国产小视频在线观看| 亚洲一区二区三区四区在线免费观看 | 99久久99久久精品免费看蜜桃| 中文av一区二区| 色综合亚洲欧洲| 一区二区不卡在线视频 午夜欧美不卡在| 99久久国产综合精品色伊| 日韩美女久久久| 在线免费观看日本欧美| 亚洲成av人影院在线观看网| 91精选在线观看| 精品一区二区三区的国产在线播放 | 美女视频免费一区| 久久综合色之久久综合| 成人不卡免费av| 亚洲一区二区三区四区中文字幕| 欧美电影在线免费观看| 国内精品国产三级国产a久久| 亚洲国产精品av| 91丨九色丨黑人外教| 亚洲v精品v日韩v欧美v专区| 日韩你懂的在线播放| 丰满白嫩尤物一区二区| 一级精品视频在线观看宜春院| 91精品国产欧美一区二区| 国产精品1024久久| 一区二区在线观看免费视频播放 | 日韩影院在线观看|