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

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

?? kavqsort.h

?? zip解壓源碼.
?? H
字號:
/***********************************************************
  Name: KAVqsort.h
  Creater: Liu Haifeng
  Date: 2000-07-25
  Description: this file define qsort() function
***********************************************************/

typedef int __cdecl comparF (const void *, const void *);

static  comparF    *Fcmp;
static  unsigned    qWidth;

/*-----------------------------------------------------------------------*

Name            Exchange - exchanges two objects

Usage           static  void  Exchange (void  *leftP, void *rightP);

Description     exchanges the qWidth byte wide objects pointed to
                by leftP and rightP.

Return value    Nothing

*------------------------------------------------------------------------*/
static  void  Exchange (void  *leftP, void *rightP)
{
        unsigned  i;
        char  c;
        char *lp = (char *)leftP;
        char *rp = (char *)rightP;

        for (i = 0; i < qWidth; i++ )
        {
                c = *rp;
                *rp++ = *lp;
                *lp++ = c;
        }
}

/*-----------------------------------------------------------------------*

Background

The Quicker Sort algorithm was first described by C.A.R.Hoare in the
Computer Journal, No. 5 (1962), pp.10..15, and in addition is frequently
described in computing literature, notably in D. Knuth's Sorting and
Searching.  The method used here includes a number of refinements:

- The median-of-three technique described by Singleton (Communications
  of the A.C.M., No 12 (1969) pp 185..187) is used, where the median
  operation is also the special case sort for 3 elements.  This slightly
  improves the average speed, especially when comparisons are slower
  than exchanges, but more importantly it prevents worst-case behavior
  on partly sorted files.  If a simplistic quicker-sort is run on a file
  which is only slightly disordered (a common need in some applications)
  then it is as slow as a bubble-sort.  The median technique prevents
  this.

  Another serious problem with the plain algorithm is that worst-case
  behavior causes very deep recursion (almost one level per table
  element !), so again it is best to use the median technique.

- The values of width and compar are copied to static storage and a help
  function with a minimum of parameters is used to reduce the recursion
  overheads.  Recursion is used both for simplicity and because there
  is no practical gain from conversion to loops: the extra housekeeping
  needed for loops needs registers for speed, but the 8086 family has not
  enough registers.  Juggling registers takes just as much time as calling
  subroutines.

*------------------------------------------------------------------------*/

/*
  Optimize pointer comparisons knowing segments are identical,
  except in HUGE model.
*/

#define _LT_(x,y)       (x < y)

/*-----------------------------------------------------------------------*

Name            qSortHelp - performs the quicker sort

Usage           static void  near pascal  qSortHelp (char *pivotP,
                                                     size_t nElem);

Description     performs the quicker sort on the nElem element array
                pointed to by pivotP.

Return value    Nothing

*------------------------------------------------------------------------*/

static void  qSortHelp (char *pivotP, size_t nElem)
{
    char     *leftP, *rightP, *pivotEnd, *pivotTemp, *leftTemp;
    unsigned  lNum;
    int       retval;


tailRecursion:
    if (nElem <= 2)
        {
        if (nElem == 2)
            {
            if (Fcmp (pivotP, rightP = qWidth + pivotP) > 0)
                Exchange (pivotP, rightP);
            }
        return;
        }

    rightP = (nElem - 1) * qWidth + pivotP;
    leftP  = (nElem >> 1) * qWidth + pivotP;

/*  sort the pivot, left, and right elements for "median of 3" */

    if (Fcmp (leftP, rightP) > 0)
        Exchange (leftP, rightP);
    if (Fcmp (leftP, pivotP) > 0)
        Exchange (leftP, pivotP);
    else if (Fcmp (pivotP, rightP) > 0)
        Exchange (pivotP, rightP);

    if (nElem == 3)
        {
        Exchange (pivotP, leftP);
        return;
        }

/*  now for the classic Hoare algorithm */

    leftP = pivotEnd = pivotP + qWidth;

    do
        {
        while ((retval = Fcmp(leftP, pivotP)) <= 0)
            {
            if (retval == 0)
                {
                Exchange(leftP, pivotEnd);
                pivotEnd += qWidth;
                }
            if (_LT_ (leftP, rightP))
                leftP += qWidth;
            else
                goto qBreak;
            }

        while (_LT_(leftP, rightP))
            {
            if ((retval = Fcmp(pivotP, rightP)) < 0)
                rightP -= qWidth;
            else
                {
                Exchange (leftP, rightP);
                if (retval != 0)
                    {
                    leftP += qWidth;
                    rightP -= qWidth;
                    }
                break;
                }
            }
        }   while (_LT_(leftP, rightP));

qBreak:

    if (Fcmp(leftP, pivotP) <= 0)
        leftP = leftP + qWidth;

    leftTemp = leftP - qWidth;
        
    pivotTemp = pivotP;
        
    while ((pivotTemp < pivotEnd) && (leftTemp >= pivotEnd))
        {
        Exchange(pivotTemp, leftTemp);
        pivotTemp += qWidth;
        leftTemp -= qWidth;
        }
        
    lNum = (leftP - pivotEnd) / qWidth;
    nElem = ((nElem * qWidth + pivotP) - leftP)/qWidth;

    /* Sort smaller partition first to reduce stack usage */
    if (nElem < lNum)
        {
        qSortHelp (leftP, nElem);
        nElem = lNum;
        }
    else
        {
        qSortHelp (pivotP, lNum);
        pivotP = leftP;
        }
                
    goto tailRecursion;
}   

/*-----------------------------------------------------------------------*

Name            qsort - sorts using the quick sort routine

Usage           void qsort(void *base, int nelem, int width, int (*fcmp)());

Prototype in    stdlib.h

Description     qsort is an implementation of the "median of three"
                variant of the quicksort algorithm. qsort sorts the entries
                in a table into order by repeatedly calling the user-defined
                comparison function pointed to by fcmp.

                base points to the base (0th element) of the table to be sorted.

                nelem is the number of entries in the table.

                width is the size of each entry in the table, in bytes.

                *fcmp, the comparison function, accepts two arguments, elem1
                and elem2, each a pointer to an entry in the table. The
                comparison function compares each of the pointed-to items
                (*elem1 and *elem2), and returns an integer based on the result
                of the comparison.

                        If the items            fcmp returns

                        *elem1 <  *elem2         an integer < 0
                        *elem1 == *elem2         0
                        *elem1 >  *elem2         an integer > 0

                In the comparison, the less than symbol (<) means that the left
                element should appear before the right element in the final,
                sorted sequence. Similarly, the greater than (>) symbol
                means that the left element should appear after the right
                element in the final, sorted sequence.

Return value    qsort does not return a value.

*------------------------------------------------------------------------*/

void __cdecl qsort(void *baseP, size_t nElem, size_t width,
                          comparF *compar)

/*
  The table *baseP containing a count of nElem records each of fixed width
  is to be converted from unknown order into ascending order, using the
  ordering provided by the comparison function compar.

  The comparison function compar (leftP, rightP) must return less than, equal,
  or greater than zero, according to whether it decides that (record) *leftP
  is less than, equal, or greater than (record) *rightP.

  The internal contents of the records are never inspected by qsort.  It
  depends entirely upon compar to decide the format and value of the records.
  This allows the content of the records to be of any fixed length type -
  formatted text, floating point, pointer to variable length record, etc. -
  so long as each record is understood by compar.

  The quicker sort algorithm will in general change the relative ordering
  of records which may compare as equal.  For example, if it is attempted
  to use two passes of quick sort on a order file, first by date and then
  by customer name, the result will be that the second sort pass randomly
  jumbles the dates.  It is necessary to design the compar() function to
  consider all the keys and sort in one pass.

*/

{
    if ((qWidth = width) == 0)
        return;

    Fcmp = compar;

    qSortHelp ((char *)baseP, nElem);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人精品国产福利| 欧美成人高清电影在线| 51午夜精品国产| 亚洲手机成人高清视频| 久久av中文字幕片| 在线日韩av片| 国产精品丝袜一区| 国产一区二区三区黄视频 | 亚洲第一精品在线| 国产福利电影一区二区三区| 91精品国产入口在线| 洋洋av久久久久久久一区| 国产a区久久久| 久久综合五月天婷婷伊人| 亚洲va在线va天堂| 欧洲激情一区二区| 亚洲一区二区综合| 91影视在线播放| 中文字幕一区二区三区在线观看| 狠狠色狠狠色合久久伊人| 欧美日韩精品免费观看视频| 一区2区3区在线看| 在线视频中文字幕一区二区| 亚洲欧美日韩国产成人精品影院 | 亚洲第一会所有码转帖| 91久久精品日日躁夜夜躁欧美| 亚洲国产精品传媒在线观看| 国产精品 欧美精品| 久久精品夜色噜噜亚洲a∨| 国精产品一区一区三区mba视频| 日韩精品中午字幕| 久久国产麻豆精品| 欧美精品一区二区三区蜜桃 | 亚洲一区视频在线| 欧美在线播放高清精品| 亚洲国产一区二区三区青草影视 | 99视频一区二区| 日韩一区欧美小说| 不卡av免费在线观看| 国产精品嫩草久久久久| 91在线看国产| 亚洲精品国产无套在线观 | 99精品久久久久久| 成人99免费视频| 日本一二三不卡| 91视视频在线观看入口直接观看www| 国产精品乱人伦中文| 91丨九色porny丨蝌蚪| 亚洲一线二线三线视频| 欧美一卡二卡三卡四卡| 精品一区二区三区免费播放| 久久青草国产手机看片福利盒子 | 久久久久久亚洲综合| 国产99久久久国产精品潘金| 中文字幕一区二区三| 欧美亚洲动漫精品| 久久超碰97人人做人人爱| 久久欧美中文字幕| 91在线精品秘密一区二区| 亚洲小说春色综合另类电影| 51精品秘密在线观看| 成人一区二区在线观看| 一区二区三区精品久久久| 91精品久久久久久久91蜜桃| 东方欧美亚洲色图在线| 一区二区三区中文免费| 精品国产髙清在线看国产毛片| 国产成人av一区| 亚洲一区二区3| 2023国产精品视频| 在线一区二区观看| 国内不卡的二区三区中文字幕| 亚洲免费电影在线| 精品免费视频.| 日本精品一级二级| 国产二区国产一区在线观看| 一区二区三区不卡视频| 国产亚洲一区二区在线观看| 欧美日韩色一区| 成人a级免费电影| 麻豆精品视频在线观看| 1024成人网| 久久夜色精品国产噜噜av| 在线区一区二视频| 国产91丝袜在线播放九色| 视频一区在线视频| 樱桃国产成人精品视频| 久久女同互慰一区二区三区| 欧美日韩一二区| av欧美精品.com| 国产成人综合网站| 久久激情五月激情| 婷婷六月综合亚洲| 亚洲久草在线视频| 国产精品不卡在线| 国产日韩视频一区二区三区| 日韩久久久精品| 91精品国产色综合久久ai换脸| 色伊人久久综合中文字幕| 成人高清免费观看| 国产成人免费xxxxxxxx| 国产毛片精品视频| 美女一区二区视频| 奇米777欧美一区二区| 亚洲妇熟xx妇色黄| 国产综合色产在线精品| 91福利区一区二区三区| 99视频在线精品| 91香蕉国产在线观看软件| 成人久久视频在线观看| 东方欧美亚洲色图在线| 成人小视频免费在线观看| 国产成人免费av在线| 国产成人久久精品77777最新版本| 国内精品国产成人| 国产精品亚洲视频| 国产成人啪免费观看软件| 成人污视频在线观看| 成人精品电影在线观看| 91免费国产视频网站| 日本韩国视频一区二区| 在线国产亚洲欧美| 欧美专区日韩专区| 91麻豆精品国产自产在线观看一区| 欧美一级日韩免费不卡| 精品国产免费视频| 国产日韩欧美a| 综合av第一页| 亚洲第一综合色| 麻豆精品久久久| 丁香激情综合五月| 91小视频在线观看| 欧美肥胖老妇做爰| 欧美大胆人体bbbb| 国产三区在线成人av| ...中文天堂在线一区| 亚洲一区二区三区爽爽爽爽爽| 欧美一区二区在线视频| 一区二区三区波多野结衣在线观看 | 欧美刺激脚交jootjob| 国产精品电影一区二区三区| 国产精品一区二区久激情瑜伽| 久久亚洲捆绑美女| 粉嫩aⅴ一区二区三区四区五区| 亚洲韩国精品一区| 色综合久久99| 久久久五月婷婷| 亚洲一区二区美女| 国产一区二区三区四区在线观看| 一本色道久久综合亚洲91| 久久亚洲精华国产精华液| 亚洲成人自拍偷拍| 欧美在线免费视屏| 亚洲精选免费视频| 在线日韩一区二区| 日韩一区在线看| www.欧美.com| 综合久久国产九一剧情麻豆| 粉嫩嫩av羞羞动漫久久久| 国产精品久久久久毛片软件| 国产精品白丝av| 国产精品区一区二区三区| 成人v精品蜜桃久久一区| 日韩专区中文字幕一区二区| 国产成人免费在线观看| 亚洲香蕉伊在人在线观| 丁香天五香天堂综合| 日韩成人一级片| 亚洲欧美区自拍先锋| 99久久精品国产一区二区三区 | 欧美人动与zoxxxx乱| 亚洲视频在线观看一区| 老司机免费视频一区二区三区| 亚洲嫩草精品久久| 久久久午夜电影| av一区二区三区在线| 精品视频在线免费看| 亚洲国产一二三| 国产精品久久久久婷婷二区次 | 一区二区三区成人| 国产精品麻豆欧美日韩ww| 日韩网站在线看片你懂的| 懂色av一区二区三区蜜臀| 日本亚洲视频在线| 国产精品欧美一区二区三区| 在线电影院国产精品| 一个色在线综合| 国产亚洲精品7777| 国产一区二区三区香蕉| 国产精品国产馆在线真实露脸 | 亚洲欧美一区二区三区极速播放 | 午夜精品久久久久| 91麻豆国产精品久久| 亚洲男女毛片无遮挡| 56国语精品自产拍在线观看| 黄页视频在线91| 国v精品久久久网| 2欧美一区二区三区在线观看视频| 婷婷开心激情综合| 欧美日韩国产不卡|