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

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

?? qsort.c

?? vxwork源代碼
?? C
字號:
/* qsort.c - qsort file for stdlib  *//* Copyright 1992-1993 Wind River Systems, Inc. *//*modification history--------------------01d,01jul93,jmm  fixed parameter order of quick_sort and insertion_sort (spr 2202)01c,08feb93,jdi  documentation cleanup for 5.1.01b,20sep92,smb  documentation additions.01a,19jul92,smb  written and documented.*//*DESCRIPTION * Copyright (c) 1980, 1983, 1990 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. *INCLUDE FILES: stdlib.hSEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "stdlib.h"/* * MTHRESH is the smallest partition for which we compare for a median * value instead of using the middle value. */#define	MTHRESH	6/* * THRESH is the minimum number of entries in a partition for continued * partitioning. */#define	THRESH	4static void insertion_sort(), quick_sort(); /* * Swap two areas of size number of bytes.  Although qsort(3) permits random * blocks of memory to be sorted, sorting pointers is almost certainly the * common case (and, were it not, could easily be made so).  Regardless, it * isn't worth optimizing; the SWAP's get sped up by the cache, and pointer * arithmetic gets lost in the time required for comparison function calls. */#define	SWAP(a, b) 						\    {						 		\    cnt = size; 						\    do 								\	{ 							\    	ch = *a; 						\    	*a++ = *b; 						\    	*b++ = ch; 						\        } while (--cnt); 					\    }/* * Knuth, Vol. 3, page 116, Algorithm Q, step b, argues that a single pass * of straight insertion sort after partitioning is complete is better than * sorting each small partition as it is created.  This isn't correct in this * implementation because comparisons require at least one (and often two) * function calls and are likely to be the dominating expense of the sort. * Doing a final insertion sort does more comparisons than are necessary * because it compares the "edges" and medians of the partitions which are * known to be already sorted. * * This is also the reasoning behind selecting a small THRESH value (see * Knuth, page 122, equation 26), since the quicksort algorithm does less * comparisons than the insertion sort. */#define	SORT(bot, n) 						\    { 								\    if (n > 1) 							\    	if (n == 2) 						\	    { 							\    	    t1 = bot + size; 					\    	    if (compar (t1, bot) < 0) 				\    	    	SWAP (t1, bot); 				\    	    } 							\	else 							\    	    insertion_sort(bot, n, size, compar); 		\    }/******************************************************************************** qsort - sort an array of objects (ANSI)** This routine sorts an array of <nmemb> objects, the initial element of* which is pointed to by <bot>.  The size of each object is specified by* <size>.** The contents of the array are sorted into ascending order according to a* comparison function pointed to by <compar>, which is called with two* arguments that point to the objects being compared.  The function shall* return an integer less than, equal to, or greater than zero if the first* argument is considered to be respectively less than, equal to, or greater* than the second.** If two elements compare as equal, their order in the sorted array is* unspecified.** INCLUDE FILES: stdlib.h** RETURNS: N/A*/void qsort    (    void *	bot,		/* initial element in array */    size_t	nmemb,		/* no. of objects in array */    size_t	size,		/* size of array element */    int	(*compar) (const void *, const void *)  /* comparison function */    )    {    /* static void insertion_sort(), quick_sort(); */    if (nmemb <= 1)    	return;    if (nmemb >= THRESH)    	quick_sort (bot, nmemb, size, compar);    else    	insertion_sort (bot, nmemb, size, compar);    }/******************************************************************************** quick_sort - sort an array of objects.** RETURNS: no value.* NOMANUAL*/static void quick_sort    (    FAST char *  bot,    int          nmemb,    FAST int     size,    int          (*compar)()    )    {    FAST int 	  cnt;    FAST uint_t	  ch;    FAST char *   top;    FAST char *   mid;    FAST char *   t1;    FAST char *   t2;    FAST int      n1;    FAST int      n2;    char *        bsv;    /* bot and nmemb must already be set. */partition:    /* find mid and top elements */    mid = bot + size * (nmemb >> 1);    top = bot + (nmemb - 1) * size;    /*     * Find the median of the first, last and middle element (see Knuth,     * Vol. 3, page 123, Eq. 28).  This test order gets the equalities     * right.     */    if (nmemb >= MTHRESH) 	{    	n1 = compar (bot, mid);    	n2 = compar (mid, top);    	if ((n1 < 0) && (n2 > 0))    		t1 = compar (bot, top) < 0 ? top : bot;    	else 	    if ((n1 > 0) && (n2 < 0))    		t1 = compar (bot, top) > 0 ? top : bot;    	else    		t1 = mid;        /* if mid element not selected, swap selection there */        if (t1 != mid)             {            SWAP (t1, mid);            mid -= size;            }        }    /* Standard quicksort, Knuth, Vol. 3, page 116, Algorithm Q. */#define	didswap	n1#define	newbot	t1#define	replace	t2    didswap = 0;    bsv = bot;    FOREVER	{    	while ((bot < mid) && (compar (bot, mid) <= 0))	    {	    bot += size;	    }    	while (top > mid) 	    {    	    if (compar (mid, top) <= 0) 		{    	    	top -= size;    	    	continue;    	        }    	    newbot = bot + size;	/* value of bot after swap */    	    if (bot == mid)		/* top <-> mid, mid == top */    	    	replace = mid = top;    	    else 		{			/* bot <-> top */    	    	replace = top;    	    	top -= size;    	        }    	    goto swap;    	    }    	if (bot == mid)    		break;    	/* bot <-> mid, mid == bot */    	replace = mid;    	newbot = mid = bot;		/* value of bot after swap */    	top -= size;swap:	SWAP(bot, replace);    	bot = newbot;    	didswap = 1;        }    /*     * Quicksort behaves badly in the presence of data which is already     * sorted (see Knuth, Vol. 3, page 119) going from O N lg N to O N^2.     * To avoid this worst case behavior, if a re-partitioning occurs     * without swapping any elements, it is not further partitioned and     * is insert sorted.  This wins big with almost sorted data sets and     * only loses if the data set is very strangely partitioned.  A fix     * for those data sets would be to return prematurely if the insertion     * sort routine is forced to make an excessive number of swaps, and     * continue the partitioning.     */    if (!didswap) 	{    	insertion_sort (bsv, nmemb, size, compar);    	return;        }    /*     * Re-partition or sort as necessary.  Note that the mid element     * itself is correctly positioned and can be ignored.     */#define	nlower	n1#define	nupper	n2    bot = bsv;    nlower = (mid - bot) / size;	/* size of lower partition */    mid += size;    nupper = nmemb - nlower - 1;	/* size of upper partition */    /*     * If must call recursively, do it on the smaller partition; this     * bounds the stack to lg N entries.     */    if (nlower > nupper) 	{    	if (nupper >= THRESH)    	    quick_sort (mid, nupper, size, compar);    	else 	    {    	    SORT (mid, nupper);    	    if (nlower < THRESH) 		{    	    	SORT (bot, nlower);    	    	return;    	        }    	    }    	nmemb = nlower;        }     else 	{    	if (nlower >= THRESH)    	    quick_sort (bot, nlower, size, compar);    	else 	    {    	    SORT (bot, nlower);    	    if (nupper < THRESH) 		{    		SORT (mid, nupper);    		return;    		}    	    }    	bot = mid;    	nmemb = nupper;        }    goto partition;    /* NOTREACHED */    }/******************************************************************************** insertion_sort - internal routine** RETURNS: no value.* NOMANUAL*/static void insertion_sort    (    char *       bot,    int          nmemb,    FAST int     size,    int          (*compar)()    )    {    FAST int     cnt;    FAST uint_t  ch;    FAST char *  s1;    FAST char *  s2;    FAST char *  t1;    FAST char *  t2;    FAST char *  top;    /*     * A simple insertion sort (see Knuth, Vol. 3, page 81, Algorithm     * S).  Insertion sort has the same worst case as most simple sorts     * (O N^2).  It gets used here because it is (O N) in the case of     * sorted data.     */    top = bot + nmemb * size;    for (t1 = bot + size; t1 < top;) 	{    	for (t2 = t1; ((t2 -= size) >= bot) && (compar (t1, t2) < 0);)	    ;    	if (t1 != (t2 += size)) 	    {    	    /* Bubble bytes up through each element. */    	    for (cnt = size; cnt--; ++t1) 		{    	    	ch = *t1;    	    	for (s1 = s2 = t1; (s2 -= size) >= t2; s1 = s2)		    {    	    	    *s1 = *s2;		    }    	    	*s1 = ch;    	        }    	    }         else    	    t1 += size;        }    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩经典中文字幕一区| 精品理论电影在线观看| aaa国产一区| 国产高清精品久久久久| 国产精品456| 成人午夜电影小说| 99天天综合性| 欧美日韩一区小说| 日韩一区二区三区观看| 精品久久国产97色综合| 国产午夜亚洲精品午夜鲁丝片 | 亚洲激情成人在线| 亚洲在线视频一区| 日韩av电影免费观看高清完整版| 日韩电影免费一区| 国产经典欧美精品| 91精品福利视频| 日韩亚洲欧美成人一区| 国产亚洲美州欧州综合国| 国产精品理论片在线观看| 亚洲午夜三级在线| 麻豆91在线看| 色综合久久综合网| 日韩欧美国产一区二区在线播放| 精品欧美一区二区久久| 国产精品久久久久久亚洲伦| 一区二区三区四区在线| 美腿丝袜亚洲一区| av一区二区三区在线| 在线播放一区二区三区| 国产日韩欧美麻豆| 首页综合国产亚洲丝袜| 成人午夜免费av| 5858s免费视频成人| 亚洲国产成人午夜在线一区| 亚洲成人动漫在线免费观看| 国产一区二区福利视频| 欧美日韩黄色一区二区| 日本一区二区视频在线| 五月天精品一区二区三区| 成人激情免费视频| 日韩一级完整毛片| 亚洲精品大片www| 国产传媒日韩欧美成人| 91精品国产全国免费观看| 亚洲国产岛国毛片在线| 精品在线播放午夜| 欧美日韩激情一区二区三区| 国产精品电影一区二区三区| 亚洲色图欧美在线| 国产一区二区在线看| 欧美日韩不卡视频| 国产精品视频麻豆| 久久99精品久久久久久国产越南 | 亚洲男人天堂av| 一本到三区不卡视频| 欧美精品丝袜中出| 一级特黄大欧美久久久| 成人激情电影免费在线观看| 日韩精品一区二区三区视频播放 | 色系网站成人免费| 中文字幕免费不卡| 国产激情91久久精品导航| 正在播放亚洲一区| 午夜在线电影亚洲一区| 91精品福利视频| 亚洲综合一区二区三区| 一本高清dvd不卡在线观看| 国产精品大尺度| 99热精品国产| 亚洲欧美怡红院| 91视频你懂的| 亚洲免费观看高清| 色婷婷综合激情| 亚洲影视资源网| 91精品办公室少妇高潮对白| 久久久不卡网国产精品一区| 日韩电影在线一区二区| 欧美写真视频网站| 天堂影院一区二区| 日韩一级欧美一级| 视频一区二区国产| 欧美一级片在线| 久久国产精品色婷婷| 日韩欧美色综合网站| 国模一区二区三区白浆| 久久免费国产精品| 99精品国产91久久久久久| 亚洲女厕所小便bbb| 欧美三级韩国三级日本一级| 午夜影院久久久| 日韩美女一区二区三区| 国产成人精品免费一区二区| 亚洲欧美偷拍另类a∨色屁股| 欧美性生活大片视频| 日韩国产欧美在线观看| 久久你懂得1024| 粉嫩一区二区三区在线看| 色天使久久综合网天天| 亚洲一区二区三区四区在线 | 一区二区理论电影在线观看| 一本一道久久a久久精品| 国产精品国产自产拍在线| 在线一区二区视频| 久久不见久久见免费视频7| 国产精品国产成人国产三级| 欧美亚洲一区二区三区四区| 麻豆91精品视频| 1024国产精品| 欧美xfplay| a在线播放不卡| 老色鬼精品视频在线观看播放| 中文字幕免费观看一区| 欧美日韩国产经典色站一区二区三区| 精品一区二区三区视频 | 免费一级片91| 久久久久久影视| 在线日韩国产精品| 国产九色精品成人porny| 亚洲二区视频在线| 1区2区3区欧美| 欧美tickling挠脚心丨vk| 在线观看亚洲专区| 丁香六月久久综合狠狠色| 午夜精品久久久久| 亚洲欧美精品午睡沙发| 久久久久久久一区| 3d动漫精品啪啪| 欧美私人免费视频| 99精品桃花视频在线观看| 极品少妇一区二区| 日韩和欧美一区二区三区| 亚洲摸摸操操av| 久久精品亚洲精品国产欧美kt∨ | 成人av在线电影| 裸体歌舞表演一区二区| 亚洲不卡一区二区三区| 最新国产精品久久精品| 国产亚洲成aⅴ人片在线观看 | 久久久蜜桃精品| 欧美成人vr18sexvr| 欧美一卡二卡在线观看| 4438亚洲最大| 777欧美精品| 欧美精品日韩精品| 欧美三级视频在线播放| 国产xxx精品视频大全| 麻豆精品在线播放| 久久精品日产第一区二区三区高清版 | 奇米色777欧美一区二区| 亚洲影院在线观看| 亚洲国产精品久久人人爱| 中文字幕中文在线不卡住| 久久婷婷国产综合国色天香| 精品久久一二三区| 精品久久五月天| 欧美国产乱子伦 | 精品日韩在线观看| 欧美一级专区免费大片| 日韩三级在线免费观看| 欧美成人伊人久久综合网| 精品福利视频一区二区三区| 久久久久久久电影| 国产嫩草影院久久久久| 国产精品久久久久四虎| 亚洲激情自拍视频| 亚洲一区二区精品3399| 日韩—二三区免费观看av| 一区二区三区久久久| 日韩主播视频在线| 日本91福利区| 国产成人在线看| 99久久国产综合精品色伊| 91国偷自产一区二区使用方法| 欧美中文字幕一区二区三区亚洲| 欧美日韩一区二区三区四区五区| 欧美日韩国产123区| 久久久久久免费毛片精品| 国产精品久久三| 五月婷婷综合网| 国产精品中文字幕一区二区三区| 成人性生交大片免费看视频在线 | 在线播放国产精品二区一二区四区 | 久久青草国产手机看片福利盒子| 国产欧美一区二区精品性| 亚洲日穴在线视频| 一区二区三区在线高清| 免费在线成人网| 99精品久久只有精品| 欧美日韩一区二区在线视频| 久久婷婷国产综合精品青草 | 这里只有精品电影| 国产精品久久久久婷婷| 视频精品一区二区| 北条麻妃一区二区三区| 69久久99精品久久久久婷婷 | 欧美色综合网站| 亚洲国产精品精华液2区45| 亚洲一区在线观看免费| 国产精品一线二线三线精华|