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

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

?? qsort.c

?? vxworks的源代碼
?? 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一区二区三区免费野_久草精品视频
亚洲精品视频在线观看免费| 欧美一区二区三区思思人| 中文字幕乱码日本亚洲一区二区| 国产自产v一区二区三区c| 日韩欧美亚洲国产另类| 狠狠久久亚洲欧美| 国产精品不卡在线观看| 色激情天天射综合网| 日韩中文字幕av电影| 精品国产一区二区三区不卡| 丰满放荡岳乱妇91ww| 中文字幕一区二区三区不卡| 欧洲国内综合视频| 麻豆精品久久久| 国产欧美日本一区二区三区| 91视频com| 日韩精品三区四区| 欧美国产一区二区| 欧美图区在线视频| 久久国产精品第一页| 国产午夜亚洲精品不卡| 欧美一级专区免费大片| 黑人精品欧美一区二区蜜桃| 亚洲国产成人在线| 欧美区在线观看| 国产黄色精品视频| 亚洲综合免费观看高清在线观看| 日韩一区二区视频在线观看| 成人午夜精品在线| 视频一区二区欧美| 中文字幕免费一区| 欧美一区二区视频网站| 成人精品视频.| 蜜臀av性久久久久蜜臀aⅴ流畅| 国产亚洲成av人在线观看导航| 91福利小视频| 精品一区二区精品| 亚洲一区二区三区美女| 国产日韩欧美电影| 日韩一区二区三区在线| 91麻豆精品秘密| 国产精品一区久久久久| 视频一区二区欧美| 亚洲免费伊人电影| 日本一区二区免费在线观看视频| 欧美在线播放高清精品| 成人午夜免费电影| 精油按摩中文字幕久久| 无吗不卡中文字幕| 亚洲免费观看视频| 亚洲国产精品国自产拍av| 91精品国产综合久久久久久久| aa级大片欧美| 国产成人亚洲综合a∨婷婷| 日韩高清不卡一区二区三区| 亚洲人被黑人高潮完整版| 国产三级精品三级| 26uuu精品一区二区| 日韩视频一区二区三区在线播放| 在线观看成人免费视频| 91在线观看下载| 国产成人自拍在线| 国产中文一区二区三区| 久久 天天综合| 日韩电影免费一区| 日日摸夜夜添夜夜添亚洲女人| 一区二区三区久久久| 1024成人网| 中文字幕电影一区| 国产婷婷精品av在线| 久久久久久亚洲综合影院红桃| 日韩欧美一区二区免费| 日韩女优视频免费观看| 欧美一区二区三区免费| 日韩写真欧美这视频| 欧美一级二级三级乱码| 欧美一级一级性生活免费录像| 欧美日韩国产综合一区二区| 欧美日韩午夜影院| 欧美日韩国产乱码电影| 欧美日韩精品福利| 3d动漫精品啪啪一区二区竹菊 | 国产亚洲欧美日韩日本| 久久久久青草大香线综合精品| 精品国产免费久久 | 欧美日韩精品免费| 欧美丰满美乳xxx高潮www| 7777精品伊人久久久大香线蕉完整版| 51精品久久久久久久蜜臀| 日韩美一区二区三区| 久久久一区二区三区| 国产欧美一区二区精品久导航| 国产拍欧美日韩视频二区| 综合激情网...| 亚洲综合在线第一页| 青青草97国产精品免费观看无弹窗版 | 91丨九色丨尤物| 欧美无砖专区一中文字| 日韩一区二区三区视频在线观看| 精品国产sm最大网站| 中文字幕不卡三区| 一区二区三区在线免费视频| 五月天一区二区三区| 国产一区二区在线视频| 91在线视频网址| 欧美理论片在线| 精品久久久久99| 国产精品久久久一本精品 | 欧美日韩国产精选| 日韩免费观看2025年上映的电影 | 欧美大片一区二区| 国产精品素人一区二区| 洋洋av久久久久久久一区| 美腿丝袜亚洲一区| 懂色av一区二区夜夜嗨| 欧美日韩高清一区| 国产亚洲人成网站| 午夜久久久久久电影| 国产精品123区| 欧美日韩亚洲综合在线| 国产日韩欧美不卡在线| 石原莉奈一区二区三区在线观看 | 成人美女视频在线观看| 在线观看网站黄不卡| 久久久精品人体av艺术| 亚洲电影一区二区三区| 国产精品自拍一区| 欧美片在线播放| 亚洲视频你懂的| 九九精品视频在线看| 欧美日韩一区二区三区在线| 久久网站最新地址| 亚洲永久精品大片| 高清国产一区二区| 91精品国产欧美一区二区成人| 国产精品精品国产色婷婷| 麻豆成人久久精品二区三区红| 99精品视频一区| 久久久国产午夜精品| 蜜臀a∨国产成人精品| 在线国产亚洲欧美| 中文字幕欧美一| 经典一区二区三区| 欧美一区二区三区视频免费播放 | 国产欧美日韩麻豆91| 精品在线观看免费| 欧美一级电影网站| 亚洲成av人影院在线观看网| 99久久精品国产网站| 国产午夜精品在线观看| 激情综合色综合久久| 91精品国产综合久久久久久| 奇米影视一区二区三区| 在线视频一区二区三| 亚洲欧美日韩国产综合在线| 懂色av一区二区夜夜嗨| 国产视频在线观看一区二区三区| 久久国产夜色精品鲁鲁99| 欧美一区二区三区播放老司机 | 偷拍日韩校园综合在线| 欧美在线播放高清精品| 亚洲蜜臀av乱码久久精品蜜桃| av午夜精品一区二区三区| 亚洲国产高清aⅴ视频| 成人小视频免费观看| 中文字幕欧美激情| 99视频超级精品| 国产精品久久久久久久久免费丝袜 | 国产成人在线色| 久久久久久久久99精品| 国产成人亚洲综合a∨婷婷| 久久天堂av综合合色蜜桃网| 狠狠色综合播放一区二区| 精品嫩草影院久久| 韩国精品一区二区| 亚洲精品在线电影| 国产麻豆视频一区| 欧美极品aⅴ影院| 97精品国产97久久久久久久久久久久 | 国产精品情趣视频| 99精品久久只有精品| 亚洲一区二区三区四区在线| 欧美日韩精品一区二区三区 | 久88久久88久久久| 久久久久久亚洲综合影院红桃 | 91小视频在线| 亚洲成人在线免费| 日韩精品一区在线| 国产成人在线视频免费播放| 中文字幕中文乱码欧美一区二区| 色一区在线观看| 天天av天天翘天天综合网| 欧美一区日韩一区| 激情六月婷婷久久| 18欧美亚洲精品| 欧美精品日韩一本| 国内精品久久久久影院色| 国产精品久久久久久久第一福利| 精久久久久久久久久久| 精品国产乱码久久久久久牛牛|