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

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

?? sort.c

?? C語言實戰105例的光盤所附程序
?? C
?? 第 1 頁 / 共 2 頁
字號:

         /*
          * now, lets look at the low list and the high list.  save the node
          *  pointers and counters of the longest sublist on the stack.
          *  then, quicksort the shortest sublist.
          */
         if (low_count > high_count) {

            /*
             * if fewer than 25 nodes in the high count, don't bother to
             *  push the stack -- sort the low list.
             */
            if (high_count > 25) {
               low_rline_stack[stack_pointer]  = low;
               high_rline_stack[stack_pointer] = low + low_count - 1;
               low_node_stack[stack_pointer]   = low_head;
               high_node_stack[stack_pointer]  = low_tail;
               ++stack_pointer;
               low       = high - high_count + 1;
               high      = high;
               low_node  = high_head;
               high_node = high_tail;
            } else {
               low       = low;
               high      = low + low_count - 1;
               low_node  = low_head;
               high_node = low_tail;
            }
         } else {

            /*
             * if fewer than 25 nodes in the low count, don't bother to
             *  push the stack -- sort the high list.
             */
            if (low_count > 25) {
               low_rline_stack[stack_pointer]  = high - high_count + 1;
               high_rline_stack[stack_pointer] = high;
               low_node_stack[stack_pointer]   = high_head;
               high_node_stack[stack_pointer]  = high_tail;
               ++stack_pointer;
               low       = low;
               high      = low + low_count - 1;
               low_node  = low_head;
               high_node = low_tail;
            } else {
               low       = high - high_count + 1;
               high      = high;
               low_node  = high_head;
               high_node = high_tail;
            }
         }

         assert( stack_pointer < 24 );
      }

      /*
       * now that we have sorted the smallest sublist, we need to pop
       *  the long sublist(s) that were pushed on the stack.
       */
      --stack_pointer;
      if (stack_pointer < 0)
         break;
      low       = low_rline_stack[stack_pointer];
      high      = high_rline_stack[stack_pointer];
      low_node  = low_node_stack[stack_pointer];
      high_node = high_node_stack[stack_pointer];
   }
}


/*
 * Name:    insertion_sort_block
 * Purpose: sort small partitions passed in by qsort
 * Date:    January 10, 1993
 * Passed:  low:          starting line in box block
 *          high:         ending line in a box block
 *          first_node:   first linked list node to sort
 * Notes:   Insertion sort the lines in the BOX buff according to stuff in
 *           a box block.
 */
void insertion_sort_block( long low, long high, line_list_ptr first_node )
{
long down;                      /* relative line number for insertion sort */
long pivot;                     /* relative line number of pivot in block */
long count;
line_list_ptr pivot_node;       /* pointer to actual text in block */
line_list_ptr down_node;        /* pointer used to compare text */
text_ptr key;
int  dirty_flag;
int  len;

   /*
    * make sure we have more than 1 line to sort.
    */
   if (low < high) {

      count = (int)(high - low) + 1;
      pivot_node = first_node->next;
      for (pivot=1; pivot < count; pivot++) {
         load_pivot( pivot_node );
         key = pivot_node->line;
         len = pivot_node->len;
         dirty_flag = pivot_node->dirty;
         down_node = pivot_node;
         for (down=pivot-1; down >= 0; down--) {
            /*
             * lets keep comparing the keys until we find the hole for
             *  pivot.
             */
            if (compare_pivot( down_node->prev ) > 0) {
               down_node->line = down_node->prev->line;
               down_node->len = down_node->prev->len;
               down_node->dirty = down_node->prev->dirty;
            } else
               break;
            down_node = down_node->prev;
         }
         down_node->line = key;
         down_node->len  = len;
         down_node->dirty = (char)dirty_flag;
         pivot_node = pivot_node->next;
      }
   }
}


/*
 * Name:    load_pivot
 * Purpose: load pivot point for insertion sort
 * Date:    June 5, 1992
 * Passed:  text:  line that contains the pivot
 */
void load_pivot( line_list_ptr node )
{
   sort.pivot_ptr = node->line;
   sort.pivot_len = node->len;
}


/*
 * Name:    compare_pivot
 * Purpose: compare pivot string with text string
 * Date:    June 5, 1992
 * Passed:  text:  pointer to current line
 * Notes:   the sort structure keeps track of the pointer to the pivot line
 *           and the pivot line length.
 */
int  compare_pivot( line_list_ptr node )
{
register int len;
register int bc;
int  rc;
int  left_over;

   len = node->len;
   bc  = sort.bc;

   assert( bc >= 0 );
   assert( len >= 0 );

   /*
    * is the current line length less than beginning column?  if so, just
    *  look at the length of the pivot line.  no need to compare keys.
    */
   if (len < bc+1) {
      if (sort.pivot_len < bc+1)
         return( 0 );
      else
         return( sort.direction == ASCENDING ?  -1 : 1 );

   /*
    * is the pivot line length less than beginning column?  if so, just
    *  look at the length of the current line.  no need to compare keys.
    */
   } else if (sort.pivot_len < bc+1) {
      if (len < bc+1)
         return( 0 );
      else
         return( sort.direction == ASCENDING ?  1 : -1 );
   } else {

      /*
       * if lines are of equal length or greater than the ending column,
       *  then lets consider them equal.
       */
      if (len == sort.pivot_len)
         left_over = 0;
      else if (len > sort.ec  &&  sort.pivot_len > sort.ec)
         left_over = 0;
      else {

         /*
          * if one line does not extend thru the ending column, give
          *  preference to the longest key.
          */
         if (sort.direction == ASCENDING)
            left_over =  len > sort.pivot_len ? 1 : -1;
         else
            left_over =  len > sort.pivot_len ? -1 : 1;
      }

      /*
       * only need to compare up to length of the key in the pivot line.
       */
      if (len > sort.pivot_len)
         len = sort.pivot_len;
      len = len - bc;
      if (len > sort.block_len)
         len = sort.block_len;

      assert( len > 0 );

      if (sort.direction == ASCENDING)
         rc = my_memcmp( node->line + bc, sort.pivot_ptr + bc, len );
      else
         rc = my_memcmp( sort.pivot_ptr + bc, node->line + bc, len );

      /*
       * if keys are equal, let's see if one key is longer than the other.
       */
      if (rc == 0)
         rc = left_over;
      return( rc );
   }
}


/*
 * Name:    my_memcmp
 * Purpose: compare strings using ignore or match case sort order
 * Date:    October 31, 1992
 * Passed:  s1:  pointer to string 1
 *          s2:  pointer to string 2
 *          len: number of characters to compare
 * Notes:   let's do our own memcmp, so we can sort languages that use
 *           extended characters as part of their alphabet.
 */
int  my_memcmp( text_ptr s1, text_ptr s2, int len )
{
unsigned char *p;
register int c;

   assert( len >= 0 );
   assert( len < MAX_LINE_LENGTH );
   assert( s1 != NULL );
   assert( s2 != NULL );

   if (len == 0)
      return( 0 );

   p = sort.order_array;

   /*
    * the C comparison function is equivalent to the assembly version;
    *  however, once the assembly routine initializes, it is much faster
    *  than the C version.
    */
   if (len < 10) {
      for (;len > 0  &&  (c = (int)p[*s1] - (int)p[*s2]) == 0;
                                              s1++, s2++, len--);
      return( c );
   } else {

      ASSEMBLE {

   /*
   ; Register strategy:
   ;   ax  == *s1
   ;   dx  == *s2
   ;   ds:[si]  == s1
   ;   es:[bx]  == s2
   ;   bp       == sort.order_array
   ;   [bp+di]  == p[*s1]  or  p[*s2]
   ;   cx       == len
   ;
   ;  CAVEAT:  sort.order_array is assumed to be located in the stack segment
   */

        push    ds                      /* push required registers */
        push    si
        push    di
        push    bp

        xor     ax, ax                  /* zero ax */
        mov     cx, WORD PTR len        /* keep len in cx */
        cmp     cx, 0                   /* len <= 0? */
        jle     get_out                 /* yes, get out */

        mov     bx, WORD PTR s2         /* load our registers */
        mov     ax, WORD PTR s2+2
        mov     es, ax                  /* es:[bx] = s2 */
        mov     si, WORD PTR s1
        mov     ax, WORD PTR s1+2
        mov     ds, ax                  /* ds:[si] = s1 */
        mov     bp, p                   /* [bp] = p */
        xor     ax, ax                  /* zero out ax */
        xor     dx, dx                  /* zero out dx */
      }
top:

   ASSEMBLE {
        mov     al, BYTE PTR ds:[si]    /* al == *s1 */
        mov     di, ax
        mov     al, BYTE PTR [bp+di]    /* al == p[*s1] */
        mov     dl, BYTE PTR es:[bx]    /* dl == *s2 */
        mov     di, dx
        mov     dl, BYTE PTR [bp+di]    /* dl == p[*s2] */
        sub     ax, dx                  /* ax == p[*s1] - p[*s2] */
        jne     get_out
        inc     bx
        inc     si
        dec     cx
        cmp     cx, 0
        jg      top                     /* ax keeps the return value */
      }
get_out:

   ASSEMBLE {
        pop     bp                      /* pop the registers we pushed */
        pop     di
        pop     si
        pop     ds                      /* ax keeps the return value */
      }
   }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91成人免费在线视频| 亚洲欧美日韩综合aⅴ视频| 日韩av一二三| 欧美一区二区三区视频免费| 蜜臀99久久精品久久久久久软件| 欧美日韩三级一区二区| 亚洲第一久久影院| 欧美日韩精品是欧美日韩精品| 同产精品九九九| 精品国产伦一区二区三区免费| 国产成人免费在线| **性色生活片久久毛片| 欧美中文字幕亚洲一区二区va在线| 亚洲国产精品综合小说图片区| 日韩一级大片在线| 国产很黄免费观看久久| 亚洲色图另类专区| 日韩免费观看高清完整版| 国产精品一区二区三区四区| 日韩美女精品在线| 91麻豆精品国产| 国产高清不卡二三区| 一区二区不卡在线视频 午夜欧美不卡在| 欧美日韩免费视频| 国产在线播放一区三区四| 亚洲精品中文在线影院| 日韩一卡二卡三卡四卡| 99久久国产综合精品色伊| 婷婷丁香激情综合| 国产精品久久久久9999吃药| 欧美精品 国产精品| 国产激情一区二区三区| 午夜精品成人在线视频| 国产精品丝袜黑色高跟| 欧美久久婷婷综合色| 成人性生交大片免费看视频在线| 亚洲一区二区三区美女| 国产农村妇女精品| 欧美喷潮久久久xxxxx| 东方aⅴ免费观看久久av| 丝袜亚洲精品中文字幕一区| 国产精品久久久久久久第一福利 | 亚洲高清三级视频| 国产三级三级三级精品8ⅰ区| 欧美系列日韩一区| 不卡一区中文字幕| 国产一区二区毛片| 日韩av在线发布| 一区2区3区在线看| 最新国产成人在线观看| 久久久蜜桃精品| 精品精品欲导航| 欧美精品三级日韩久久| 91久久精品一区二区三| 国产精品一区久久久久| 六月丁香婷婷色狠狠久久| 一个色综合网站| 亚洲丝袜制服诱惑| 欧美国产日韩在线观看| 欧美刺激脚交jootjob| 51久久夜色精品国产麻豆| 在线观看91精品国产入口| 不卡电影一区二区三区| 国产精品99久久久久久宅男| 久久99精品一区二区三区三区| 午夜精品福利在线| 五月婷婷久久综合| 性欧美疯狂xxxxbbbb| 亚洲一区二区三区爽爽爽爽爽| 亚洲黄色小说网站| 亚洲免费观看高清在线观看| 亚洲视频免费在线| 亚洲色图欧美在线| 亚洲精品水蜜桃| 一区二区三区四区在线免费观看| 国产精品国模大尺度视频| 中文子幕无线码一区tr| 中文字幕av在线一区二区三区| 国产情人综合久久777777| 国产日韩欧美不卡| 中文字幕一区二区三区不卡在线| 国产女同互慰高潮91漫画| 中文字幕精品一区二区三区精品| 国产欧美日本一区二区三区| 中文字幕精品一区二区精品绿巨人| 国产日韩欧美一区二区三区乱码| 国产欧美日韩三级| 国产精品国产自产拍高清av| 亚洲人吸女人奶水| 亚洲在线视频免费观看| 亚洲成av人片一区二区| 免费观看成人鲁鲁鲁鲁鲁视频| 麻豆精品在线看| 国产盗摄视频一区二区三区| www.欧美色图| 欧美午夜电影网| 91精品国产91综合久久蜜臀| 精品日韩一区二区三区| 国产亚洲短视频| 自拍偷自拍亚洲精品播放| 亚洲国产另类av| 国产在线国偷精品免费看| 国产不卡视频一区二区三区| 日本高清不卡视频| 日韩欧美国产电影| 国产精品素人视频| 日韩中文字幕av电影| 国产精品一区二区男女羞羞无遮挡| 国产99精品国产| 欧美日韩日日骚| 久久久欧美精品sm网站| 亚洲美女在线国产| 久草这里只有精品视频| 99久久婷婷国产综合精品电影 | 国产一区二区久久| 91丨九色porny丨蝌蚪| 91精品国模一区二区三区| 久久免费美女视频| 亚洲午夜精品网| 国产成人精品一区二区三区网站观看| 色一情一伦一子一伦一区| 精品国产免费人成在线观看| 一区二区三区久久| 国产在线麻豆精品观看| 欧美视频一区二区在线观看| 久久久久久久精| 亚洲午夜免费视频| 国产精品99久| 91精品国产入口在线| 国产精品传媒入口麻豆| 久久精品国产澳门| 欧美性色黄大片| 亚洲国产高清不卡| 麻豆91精品视频| 欧美日韩精品一区视频| 中文字幕中文乱码欧美一区二区| 偷拍日韩校园综合在线| 日本道精品一区二区三区| 国产女人18毛片水真多成人如厕| 免费观看久久久4p| 精品视频一区二区不卡| 椎名由奈av一区二区三区| 国产精品主播直播| 欧美tickling网站挠脚心| 亚洲成人免费在线| 欧美中文字幕一区| 日韩美女视频19| 国产a视频精品免费观看| 欧美大片一区二区三区| 天天色 色综合| 欧美性视频一区二区三区| 国产精品久久久久久久久免费樱桃| 激情五月播播久久久精品| 欧美精品免费视频| 亚洲第一狼人社区| 欧美日韩久久久久久| 亚洲尤物在线视频观看| 色综合一个色综合亚洲| 亚洲欧洲av在线| 成人动漫av在线| 国产精品国产三级国产aⅴ入口| 国产福利一区二区三区| 久久精品视频免费| 国产高清久久久| 国产精品人妖ts系列视频| 国产91精品一区二区麻豆亚洲| 精品剧情在线观看| 久草在线在线精品观看| 欧美va在线播放| 国产一区三区三区| 久久久久国产精品麻豆| 国产精品一区二区久久精品爱涩 | 日韩欧美在线影院| 免费观看成人av| 久久嫩草精品久久久久| 成人免费看的视频| 中文字幕一区二区三区在线不卡 | 综合av第一页| 欧美亚一区二区| 亚洲大尺度视频在线观看| 欧美日韩国产成人在线免费| 青青草精品视频| 欧美本精品男人aⅴ天堂| 国内精品视频666| 国产精品夫妻自拍| 欧美亚洲精品一区| 蜜臀av性久久久久蜜臀aⅴ| 2020国产成人综合网| 成人小视频免费观看| 亚洲另类春色校园小说| 欧美丝袜丝交足nylons图片| 日本sm残虐另类| 久久久99精品久久| 色噜噜狠狠成人中文综合| 亚洲成a天堂v人片| 2020国产精品自拍| 在线亚洲免费视频| 老司机精品视频导航| 国产精品国产a| 4438成人网|