亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
波多野洁衣一区| 欧美mv和日韩mv的网站| 欧美日韩亚洲综合一区二区三区| 51久久夜色精品国产麻豆| 中文字幕不卡三区| 日本欧美在线观看| 日本韩国欧美一区| 欧美—级在线免费片| 日韩国产在线一| 欧美专区日韩专区| 日韩一区在线免费观看| 久久成人免费网站| 欧美三级视频在线| 亚洲黄色录像片| 丁香婷婷综合激情五月色| 欧美一区二区成人6969| 亚洲制服丝袜在线| 99国产精品久| 国产精品网站在线播放| 久久99精品久久久久久久久久久久| 91福利在线观看| 亚洲乱码中文字幕| 99r国产精品| 国产精品乱子久久久久| 国产呦精品一区二区三区网站| 7799精品视频| 日本不卡1234视频| 日韩午夜在线观看视频| 日韩在线a电影| 欧美老女人第四色| 亚洲一区二区精品3399| 日本道色综合久久| 一区二区三区日韩欧美| 91亚洲精华国产精华精华液| 国产欧美日韩在线视频| 国产精品夜夜嗨| 国产欧美精品一区二区色综合朱莉| 国产一区二区三区在线观看精品 | 午夜久久电影网| 国产精品欧美一区二区三区| 久久av资源网| 精品国产乱码久久久久久夜甘婷婷 | 国产日韩欧美精品综合| 国产美女久久久久| 日本一区二区三区高清不卡| 成人污视频在线观看| 亚洲婷婷综合色高清在线| 97超碰欧美中文字幕| 亚洲一区二区三区免费视频| 91麻豆精品91久久久久同性| 老司机午夜精品99久久| 久久久不卡网国产精品二区| 成人av在线资源网站| 亚洲在线视频一区| 欧美一区二区网站| 国产精品91xxx| 亚洲男人的天堂av| 日韩限制级电影在线观看| 国产成人av一区二区三区在线| 国产亚洲成年网址在线观看| av不卡一区二区三区| 午夜视频在线观看一区| 欧美一卡二卡在线观看| 国产乱人伦精品一区二区在线观看 | 黄一区二区三区| 中文字幕一区二区三区四区不卡 | 性久久久久久久久久久久| 精品国产污网站| 99视频精品全部免费在线| 一区二区三区四区在线| 日韩精品专区在线影院重磅| 国产成人在线免费观看| 亚洲一区二区三区四区五区中文| 日韩一区二区电影在线| 波多野结衣欧美| 日韩高清在线一区| 中文字幕欧美国产| 日韩一区和二区| 91在线看国产| 国产一区二区不卡| 午夜精品久久久久久久久| 国产精品网站在线| 欧美mv和日韩mv的网站| 欧美性xxxxx极品少妇| 国产精品一卡二| 亚洲成人777| 亚洲欧洲精品天堂一级 | 国产一区二区三区免费| 亚洲成人手机在线| 中文一区在线播放| 久久综合久久99| 91精品国产乱码久久蜜臀| 99精品国产99久久久久久白柏 | 日本韩国一区二区三区视频| 国产一区二区三区在线观看精品 | 日本韩国欧美三级| 成人av在线电影| 国产精品亚洲人在线观看| 日本免费在线视频不卡一不卡二| 亚洲女与黑人做爰| 国产精品狼人久久影院观看方式| 精品少妇一区二区| 日韩小视频在线观看专区| 欧美男女性生活在线直播观看| 99精品国产热久久91蜜凸| 成人国产精品免费观看视频| 国产一区二区视频在线| 久久成人久久鬼色| 久久精品久久综合| 久草这里只有精品视频| 麻豆国产一区二区| 日本伊人午夜精品| 日韩va亚洲va欧美va久久| 亚洲h精品动漫在线观看| 亚洲午夜在线电影| 午夜一区二区三区视频| 亚洲一区二区影院| 亚洲成a人在线观看| 亚洲综合免费观看高清在线观看| 亚洲美女在线国产| 亚洲精品乱码久久久久久日本蜜臀| 中文字幕在线一区| 亚洲免费观看高清在线观看| 国产精品电影院| 亚洲在线视频免费观看| 首页国产欧美久久| 久久www免费人成看片高清| 黄色资源网久久资源365| 精品一区二区三区免费视频| 国产剧情一区二区| www.欧美色图| 91黄色免费观看| 91精品国产综合久久福利| 精品精品国产高清a毛片牛牛| 久久婷婷国产综合精品青草 | 五月天中文字幕一区二区| 日韩av一区二| 国产高清亚洲一区| 91啦中文在线观看| 日韩亚洲欧美在线观看| 国产女人aaa级久久久级| 一区二区三区四区亚洲| 久久国产乱子精品免费女| 成人晚上爱看视频| 欧美日韩黄视频| 久久免费美女视频| 亚洲一级二级三级在线免费观看| 秋霞电影网一区二区| 成人自拍视频在线| 欧美日韩亚州综合| 欧美高清在线精品一区| 亚洲va欧美va天堂v国产综合| 国产在线播放一区| 欧美日韩精品电影| 亚洲国产高清aⅴ视频| 亚洲成人av一区二区三区| 国产999精品久久久久久| 欧美视频一二三区| 国产欧美日韩激情| 久久精品国内一区二区三区| 色综合天天综合在线视频| 日韩欧美中文字幕制服| 国产精品美女久久久久久| 日韩电影在线观看电影| 91麻豆高清视频| 久久伊99综合婷婷久久伊| 亚洲国产视频a| av资源网一区| 国产日韩欧美综合一区| 免费成人av在线播放| 在线精品视频一区二区三四| 久久久国产精品麻豆| 麻豆一区二区三| 欧美亚洲综合一区| 综合激情成人伊人| 国产福利电影一区二区三区| 欧美一级日韩免费不卡| 亚洲一区影音先锋| 色噜噜狠狠色综合中国| 欧美国产97人人爽人人喊| 国内精品伊人久久久久av一坑| 欧美日韩精品免费| 亚洲国产综合色| 在线视频一区二区三区| 国产精品久久久久久久岛一牛影视 | 亚洲国产欧美在线| 一本久久综合亚洲鲁鲁五月天| 国产精品天干天干在观线| 黄色日韩三级电影| 精品卡一卡二卡三卡四在线| 日韩在线观看一区二区| 欧美日韩1234| 日本成人在线视频网站| 欧美男人的天堂一二区| 亚洲v日本v欧美v久久精品| 欧美午夜精品久久久久久孕妇| 亚洲免费av高清| 欧美在线观看视频一区二区| 一区二区高清免费观看影视大全 | 午夜视频在线观看一区|