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

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

?? htbtree.c

?? firtext搜索引擎源碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*								      HTBTree.c**	BINARY TREE FOR SORTING THINGS****	(c) COPYRIGHT MIT 1995.**	Please first read the full copyright statement in the file COPYRIGH.**	@(#) $Id: HTBTree.c,v 2.25 1999/01/19 11:41:11 frystyk Exp $**** Authors:**	Arthur Secret****	4 March 94: Bug fixed in the balancing procedure***//* Library include files */#include "wwwsys.h"#include "HTUtils.h"#include "HTBTree.h"#define MAXIMUM(a,b) ((a)>(b)?(a):(b))struct _HTBTree_element {    void			*object;	/* User object */    struct _HTBTree_element	*up;    struct _HTBTree_element	*left;    int				left_depth;    struct _HTBTree_element	*right;    int				right_depth;};struct _HTBTree {    HTComparer *		compare;    struct _HTBTree_element *	top;   };PUBLIC void * HTBTree_object (HTBTElement * element){    return element ? element->object : NULL;}PUBLIC HTBTree * HTBTree_new (HTComparer * comp)    /*********************************************************    ** This function returns an HTBTree with memory allocated     ** for it when given a mean to compare things    */{    HTBTree * tree;    if ((tree = (HTBTree  *) HT_CALLOC(1, sizeof(HTBTree))) == NULL)        HT_OUTOFMEM("HTBTree_new");    tree->compare = comp;    tree->top = NULL;    return tree;}PRIVATE void HTBTElement_free (HTBTElement*  element)    /**********************************************************    ** This void will HT_FREE the memory allocated for one element    */{    if (element) {        if (element->left != NULL)    HTBTElement_free(element->left);	if (element->right != NULL)    HTBTElement_free(element->right);	HT_FREE(element);    }}PUBLIC void HTBTree_free (HTBTree*  tree)    /**************************************************************    ** This void will HT_FREE the memory allocated for the whole tree    */{    HTBTElement_free(tree->top);    HT_FREE(tree);}PRIVATE void HTBTElementAndObject_free (HTBTElement*  element)    /**********************************************************    ** This void will HT_FREE the memory allocated for one element    */{    if (element) {     /* Just in case nothing was in the tree anyway */        if (element->left != NULL)    HTBTElementAndObject_free(element->left);	if (element->right != NULL)    	    HTBTElementAndObject_free(element->right);	HT_FREE(element->object);	HT_FREE(element);    }}PUBLIC void HTBTreeAndObject_free (HTBTree*  tree)    /**************************************************************    ** This void will HT_FREE the memory allocated for the whole tree    */{    HTBTElementAndObject_free(tree->top);    HT_FREE(tree);}/*** This void is the core of HTBTree.c . It will**       1/ add a new element to the tree at the right place**          so that the tree remains sorted**       2/ balance the tree to be as fast as possible when reading it*/PUBLIC void HTBTree_add (HTBTree * tree, void * object){    HTBTElement * father_of_element;    HTBTElement * added_element;    HTBTElement * forefather_of_element;    HTBTElement * father_of_forefather;    BOOL father_found,top_found;    int depth,depth2,corrections;        /* father_of_element is a pointer to the structure that is the father of the        ** new object "object".        ** added_element is a pointer to the structure that contains or will contain         ** the new object "object".        ** father_of_forefather and forefather_of_element are pointers that are used        ** to modify the depths of upper elements, when needed.        **        ** father_found indicates by a value NO when the future father of "object"         ** is found.        ** top_found indicates by a value NO when, in case of a difference of depths        **  < 2, the top of the tree is encountered and forbids any further try to        ** balance the tree.        ** corrections is an integer used to avoid infinite loops in cases        ** such as:        **        **             3                        3        **          4                              4        **           5                            5        **        ** 3 is used here to show that it need not be the top of the tree.        */    /*    ** 1/ Adding of the element to the binary tree    */    if (tree->top == NULL)    {        if ((tree->top = (HTBTElement  *) HT_MALLOC(sizeof(HTBTElement))) == NULL)            HT_OUTOFMEM("HTBTree_add");        tree->top->up = NULL;        tree->top->object = object;        tree->top->left = NULL;        tree->top->left_depth = 0;        tree->top->right = NULL;        tree->top->right_depth = 0;    }    else    {           father_found = YES;        father_of_element = tree->top;        added_element = NULL;        father_of_forefather = NULL;        forefather_of_element = NULL;              while (father_found)        {            if (tree->compare(object,father_of_element->object)<0)	    {                if (father_of_element->left != NULL)                    father_of_element = father_of_element->left;                else 	        {                    father_found = NO;                    if ((father_of_element->left = (HTBTElement  *) HT_MALLOC(sizeof(HTBTElement))) == NULL)                        HT_OUTOFMEM("HTBTree_add");                    added_element = father_of_element->left;                    added_element->up = father_of_element;                    added_element->object = object;                    added_element->left = NULL;                    added_element->left_depth = 0;                    added_element->right = NULL;                    added_element->right_depth = 0;                }   	    }            if (tree->compare(object,father_of_element->object)>=0)            {                if (father_of_element->right != NULL)                     father_of_element = father_of_element->right;                else                 {                      father_found = NO;                    if ((father_of_element->right = (HTBTElement  *) HT_MALLOC(sizeof(HTBTElement))) == NULL)                        HT_OUTOFMEM("father_of_element->right ");                    added_element = father_of_element->right;                    added_element->up = father_of_element;                    added_element->object = object;                    added_element->left = NULL;                    added_element->left_depth = 0;                    added_element->right = NULL;                    added_element->right_depth = 0;           	        }            }	}            /*            ** Changing of all depths that need to be changed            */        father_of_forefather = father_of_element;        forefather_of_element = added_element;        do        {            if (father_of_forefather->left == forefather_of_element)            {                depth = father_of_forefather->left_depth;                father_of_forefather->left_depth = 1                             + MAXIMUM(forefather_of_element->right_depth,                                  forefather_of_element->left_depth);                depth2 = father_of_forefather->left_depth;            }            else	    {                depth = father_of_forefather->right_depth;                father_of_forefather->right_depth = 1                            + MAXIMUM(forefather_of_element->right_depth,                                  forefather_of_element->left_depth);                depth2 = father_of_forefather->right_depth;            }            forefather_of_element = father_of_forefather;            father_of_forefather = father_of_forefather->up;        } while ((depth != depth2) && (father_of_forefather != NULL));                    /*            ** 2/ Balancing the binary tree, if necessary	    ** Bugs in this part have been fixed in March 94  -  AS            */        top_found = YES;        corrections = 0;        while ((top_found) && (corrections < 7))        {            if ((abs(father_of_element->left_depth                      - father_of_element->right_depth)) < 2)	    {                if (father_of_element->up != NULL)                     father_of_element = father_of_element->up;                else top_found = NO;	    }            else 	    {                /* We start the process of balancing */                corrections = corrections + 1;                    /*                     ** corrections is an integer used to avoid infinite                     ** loops in cases such as:                    **                    **             3                        3                    **          4                              4                    **           5                            5                    **                    ** 3 is used to show that it need not be the top of the tree		    ** But let's avoid these two exceptions anyhow 		    ** with the two following conditions (March 94 - AS)                    */		if ((father_of_element->left == NULL) 		    && (father_of_element->right->right == NULL) 		    && (father_of_element->right->left->left == NULL) 		    && (father_of_element->right->left->right == NULL)) 		    corrections = 7;		if ((father_of_element->right == NULL) 		    && (father_of_element->left->left == NULL) 		    && (father_of_element->left->right->right == NULL) 		    && (father_of_element->left->right->left == NULL))		    corrections = 7;                 if (father_of_element->left_depth > father_of_element->right_depth)	        {                    added_element = father_of_element->left;                    father_of_element->left_depth = added_element->right_depth;                    added_element->right_depth = 1                                    + MAXIMUM(father_of_element->right_depth,                                          father_of_element->left_depth);                    if (father_of_element->up != NULL)		    {			/* Bug fixed in March 94  */			BOOL first_time;                        father_of_forefather = father_of_element->up;                        forefather_of_element = added_element;			first_time = YES;                        do                         {                            if (father_of_forefather->left                                 == forefather_of_element->up)                              {				  depth = father_of_forefather->left_depth;				  if (first_time)				  {				      father_of_forefather->left_depth = 1					  + MAXIMUM(forefather_of_element->left_depth,						  forefather_of_element->right_depth);					first_time = NO;				   }				   else				       father_of_forefather->left_depth = 1					   + MAXIMUM(forefather_of_element->up->left_depth,					      forefather_of_element->up->right_depth);                                depth2 = father_of_forefather->left_depth;			    }                            else			    {                                depth = father_of_forefather->right_depth;				if (first_time)				{				    father_of_forefather->right_depth = 1				      + MAXIMUM(forefather_of_element->left_depth,					       forefather_of_element->right_depth);				    first_time = NO;				}								else				    father_of_forefather->right_depth = 1				      + MAXIMUM(forefather_of_element->up->left_depth,					   forefather_of_element->up->right_depth);                                depth2 = father_of_forefather->right_depth;			    }                            forefather_of_element = forefather_of_element->up;                            father_of_forefather = father_of_forefather->up;			} while ((depth != depth2) && 				 (father_of_forefather != NULL));                        father_of_forefather = father_of_element->up;                        if (father_of_forefather->left == father_of_element)	                {                            /*                            **                   3                       3                            **               4                       5                            ** When tree   5   6        becomes    7    4                            **            7 8                          8 6                            **                            ** 3 is used to show that it may not be the top of the                            ** tree.                            */                             father_of_forefather->left = added_element;                            father_of_element->left = added_element->right;                            added_element->right = father_of_element;                        }                        if (father_of_forefather->right == father_of_element)		        {                            /*                            **          3                       3                            **               4                       5                            ** When tree   5   6        becomes    7    4                            **            7 8                          8 6                            **                            ** 3 is used to show that it may not be the top of the                            ** tree                            */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
美女高潮久久久| 精品视频在线看| 精品亚洲国内自在自线福利| 亚洲bdsm女犯bdsm网站| 亚洲欧美日韩成人高清在线一区| 中文字幕av一区 二区| 久久午夜国产精品| 国产视频911| 国产色产综合产在线视频| 久久精品在线免费观看| 蜜臀久久99精品久久久久久9| 亚洲永久免费视频| 五月婷婷久久综合| 日韩av在线播放中文字幕| 天堂精品中文字幕在线| 日本一区中文字幕| 激情综合色综合久久| 国精产品一区一区三区mba桃花| 国产剧情一区二区三区| 高清久久久久久| www.日韩在线| 91黄色激情网站| 欧美日韩精品一区二区三区| 日韩西西人体444www| 精品久久国产字幕高潮| 国产亚洲欧美色| 亚洲天堂久久久久久久| 亚洲精品国产第一综合99久久 | 日韩精品专区在线影院重磅| 日韩精品最新网址| 亚洲国产成人自拍| 亚洲精品视频免费观看| 日韩精品一二三| 国产乱色国产精品免费视频| 成人激情黄色小说| 精品视频在线免费看| 26uuu国产在线精品一区二区| 国产精品久久精品日日| 亚洲一二三四区不卡| 麻豆久久一区二区| 成人av午夜电影| 欧美日本在线看| 久久精品一区八戒影视| 亚洲精品一二三| 久久99久久久久久久久久久| 国产成人无遮挡在线视频| 日本二三区不卡| 日韩精品一区在线| 自拍偷自拍亚洲精品播放| 五月天一区二区| 成人手机在线视频| 欧美日韩国产色站一区二区三区| 2023国产精品视频| 一区二区在线观看视频| 狠狠色2019综合网| 在线观看一区不卡| 国产三级一区二区| 亚洲18色成人| 99久久久久久| 精品国产成人系列| 亚洲最新在线观看| 国产成人在线免费| 91精品视频网| 亚洲三级电影网站| 国产成人在线网站| 日韩无一区二区| 亚洲免费观看高清完整版在线观看熊 | 精品国产乱码久久久久久夜甘婷婷| 成人免费在线视频观看| 蜜桃一区二区三区在线| 欧洲一区在线电影| 国产精品久久久久影院| 免费看黄色91| 欧美性videosxxxxx| 国产精品久久久久一区二区三区| 久久99国产精品免费| 欧美曰成人黄网| 亚洲日本免费电影| 国产成人啪免费观看软件| 日韩午夜av电影| 午夜精品123| 欧美午夜电影在线播放| 中文字幕视频一区二区三区久| 美脚の诱脚舐め脚责91| 欧美电影在线免费观看| 亚洲综合在线第一页| 成人app在线观看| 欧美精彩视频一区二区三区| 美女www一区二区| 欧美一卡二卡三卡| 天堂资源在线中文精品| 在线观看91视频| 亚洲老司机在线| 99视频在线精品| 国产精品乱码人人做人人爱 | 九九国产精品视频| 91麻豆精品国产91久久久久久久久 | 亚洲精品免费看| jizz一区二区| 亚洲欧美一区二区在线观看| 成人激情免费视频| 国产精品精品国产色婷婷| 国产成人综合在线播放| 久久久精品2019中文字幕之3| 精品一区二区三区在线播放视频 | 一区二区三区四区不卡视频 | 2017欧美狠狠色| 韩国在线一区二区| 久久婷婷综合激情| 国产精品99久久久久久有的能看 | 亚洲欧洲精品一区二区三区| 9人人澡人人爽人人精品| 国产日产欧美一区二区视频| 国产成人99久久亚洲综合精品| 日本一区二区久久| 9久草视频在线视频精品| 亚洲女同一区二区| 在线观看一区二区视频| 亚洲成a人v欧美综合天堂| 欧美美女一区二区| 久久精品免费观看| 久久久久久日产精品| 成人午夜伦理影院| 亚洲色图视频网站| 欧美日韩国产片| 久久99精品久久久久久国产越南| 国产亚洲1区2区3区| 不卡av电影在线播放| 一区二区三区av电影| 91精品国产综合久久精品图片| 精品综合久久久久久8888| 国产亚洲欧美中文| 91麻豆成人久久精品二区三区| 亚洲精品乱码久久久久久| 91麻豆精品国产自产在线| 国产一区二区h| 最新欧美精品一区二区三区| 在线日韩国产精品| 久久国产生活片100| 国产精品视频线看| 欧美性感一区二区三区| 国模套图日韩精品一区二区| ...xxx性欧美| 91精品国产aⅴ一区二区| 国产精品乡下勾搭老头1| 一区二区三区中文字幕在线观看| 欧美一区二区三区四区在线观看| 国产成人一区在线| 亚洲bt欧美bt精品777| 久久久99精品久久| 欧美日韩中文字幕一区二区| 国产另类ts人妖一区二区| 亚洲精品视频自拍| 日韩欧美一级二级三级久久久| 从欧美一区二区三区| 午夜激情一区二区| 国产欧美久久久精品影院| 欧美日韩免费在线视频| 国产成人精品aa毛片| 性做久久久久久久免费看| 国产网红主播福利一区二区| 欧美三级视频在线| 国产精品77777竹菊影视小说| 亚洲综合区在线| 国产日产精品一区| 欧美一级黄色片| 在线日韩av片| 成人91在线观看| 久久国产精品99久久久久久老狼 | 亚洲一区二区av电影| 久久久亚洲国产美女国产盗摄 | 一区视频在线播放| 精品福利一二区| 精品视频999| bt欧美亚洲午夜电影天堂| 蜜桃av一区二区| 亚洲国产综合色| 国产精品国产成人国产三级| 日韩欧美国产麻豆| 欧美三级午夜理伦三级中视频| 成人免费视频国产在线观看| 老司机午夜精品99久久| 亚洲18色成人| 亚洲高清视频在线| 亚洲黄色小视频| 中文字幕一区二区不卡| 久久嫩草精品久久久精品| 欧美一区二区三区四区久久| 色婷婷综合久久久久中文一区二区| 国产精品亚洲视频| 极品瑜伽女神91| 免费欧美日韩国产三级电影| 日韩精品五月天| 亚洲国产精品麻豆| 亚洲一区二区三区精品在线| 亚洲欧美国产三级| 综合电影一区二区三区| 国产精品视频观看| 中文字幕免费不卡在线| 国产欧美精品国产国产专区|