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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? sort.c

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

#include "tdestr.h"
#include "common.h"
#include "tdefunc.h"
#include "define.h"


/*
 * Name:    sort_box_block
 * Purpose: sort lines according to text in marked BOX block
 * Date:    June 5, 1992
 * Passed:  window:  pointer to current window
 * Notes:   quick sort and insertion sort the lines in the BOX buff according
 *           to stuff in a box block.
 */
int  sort_box_block( WINDOW *window )
{
int  prompt_line;
int  block_type;
line_list_ptr ll;
register file_infos *file;
WINDOW *sw;
int  rc;
char line_buff[(MAX_COLS+1)*2]; /* buffer for char and attribute  */

   /*
    * make sure block is marked OK
    */
   rc = OK;
   prompt_line = window->bottom_line;
   entab_linebuff( );
   if (un_copy_line( window->ll, window, TRUE ) == ERROR)
      return( ERROR );
   check_block( );
   if (g_status.marked == TRUE) {
      file  = g_status.marked_file;
      block_type = file->block_type;
      if (block_type == BOX) {
         /*
          * sort ascending or descending?
          */
         rc = get_sort_order( window );
         if (rc != ERROR) {
            file->modified = TRUE;
            if (mode.do_backups == TRUE) {
               sw = g_status.window_list;
               for (; ptoul( sw->file_info ) != ptoul( file );)
                  sw = sw->next;
               backup_file( sw );
            }

            /*
             * figure the width of the block.
             */
            sort.block_len = file->block_ec + 1 - file->block_bc;

            /*
             * save the prompt line and print the quicksort message.
             */
            save_screen_line( 0, prompt_line, line_buff );
            eol_clear( 0, prompt_line, g_display.text_color );
            set_prompt( block22a, prompt_line );

            /*
             * set up the sort structure.
             */
            sort.bc  = g_status.marked_file->block_bc;
            sort.ec  = g_status.marked_file->block_ec;
            sort.order_array = (mode.search_case == IGNORE) ?
                                    sort_order.ignore : sort_order.match;

            /*
             * save the previous node for use with insertion sort.
             */
            ll = file->block_start->prev;
            quick_sort_block( file->block_br, file->block_er,
                              file->block_start, file->block_end );

            /*
             * get back previous node and clean up list with insertion
             *   sort.
             */
            if (ll == NULL)
               ll = file->line_list;
            else
               ll = ll->next;
            set_prompt( block22b, prompt_line );
            insertion_sort_block( file->block_br, file->block_er, ll );

            /*
             * housekeeping.  mark the file as dirty and restore the
             *   cursors, which are scrambled during the sort.
             */
            file->dirty = GLOBAL;
            restore_cursors( file );
            restore_screen_line( 0, prompt_line, line_buff );
         }
      } else {
         /*
          * can only sort box blocks
          */
         error( WARNING, prompt_line, block23 );
         rc = ERROR;
      }
   } else {
      /*
       * box not marked
       */
      error( WARNING, prompt_line, block24 );
      rc = ERROR;
   }
   return( rc );
}


/*
 * Name:    quick_sort_block
 * Purpose: sort lines according to text in marked BOX block
 * Date:    Jaunary 10, 1993
 * Passed:  low:        starting line in box block
 *          high:       ending line in a box block
 *          low_node:   starting node in box block
 *          high_node:  ending node in box block
 * Notes:   Quicksort lines in the BOX block according to keys in
 *           a box block.
 *          because the median of three method is used to find the partion
 *           node,  high - low  should be greater than or equal to 2.
 *          with end recursion removal and sorting the smallest sublist
 *           first, our stack only needs room for log2 (N+1)/(M+2) nodes.
 *           a stack size of 24 can reliably handle almost 500 million lines.
 */
void quick_sort_block( long low, long high, line_list_ptr low_node,
                       line_list_ptr high_node )
{
long low_rline_stack[24];
long high_rline_stack[24];
line_list_ptr low_node_stack[24];
line_list_ptr high_node_stack[24];
long low_count;
long high_count;
long count;
line_list_ptr low_start;
line_list_ptr low_head;
line_list_ptr low_tail;
line_list_ptr high_end;
line_list_ptr high_head;
line_list_ptr high_tail;
line_list_ptr equal_head;
line_list_ptr equal_tail;
line_list_ptr walk_node;
line_list_ptr median_node;
int  i;
int  stack_pointer;

   assert( low_node->len != EOF);
   assert( high_node->len != EOF);

   stack_pointer = 0;
   for (;;) {

      /*
       * being that a median-of-three is used as the partition algorithm,
       *  we probably need to have at least 2 nodes in each sublist.  I
       *  chose a minimum of 25 nodes as a SWAG (scientific wild ass guess).
       *  a simple insertion sort mops the list after quicksort finishes.
       */
      while (high - low > 25) {

         assert( high >= 1 );
         assert( low  >= 1 );
         assert( low  <= high );

         /*
          * start the walk node at the head of the list and walk to the
          *  middle of the sublist.
          */
         walk_node  = low_node;
         count = (high - low) / 2;
         for (; count > 0; count--)
            walk_node = walk_node->next;

         /*
          * now, find the median of the low, middle, and high node.
          *
          * being that I am subject to error, let's assert that we really
          *  did find the median-of-three.
          */
         load_pivot( low_node );
         if (compare_pivot( walk_node ) < 0) {
            low_head   = walk_node;
            median_node = low_node;
         } else {
            low_head   = low_node;
            median_node = walk_node;
         }
         high_head = high_node;
         load_pivot( median_node );
         if (compare_pivot( high_node ) < 0) {
            high_head   = median_node;
            median_node = high_node;
         }
         load_pivot( median_node );
         if (compare_pivot( low_head ) > 0) {
            low_tail    = median_node;
            median_node = low_head;
            low_head    = low_tail;
         }

         load_pivot( median_node );

         assert( compare_pivot( low_head ) <= 0 );
         assert( compare_pivot( high_head ) >= 0 );

         /*
          * now, walk again from the head of the list comparing nodes and
          *  use the first occurrence of the median node as the partition.
          */
         walk_node = low_node;
         for (i = 0; ; walk_node = walk_node->next) {
            if (compare_pivot( walk_node ) == 0)
               break;
            i = 1;
         }

         /*
          * initialize pointers and counters for this partition.
          */
         low_start  = low_node->prev;
         high_end   = high_node->next;
         low_head   = low_tail  = NULL;
         high_head  = high_tail = NULL;
         low_count  = high_count = 0;

         /*
          * setup the first occurrence of the median node as a "fat pivot"
          *  sublist.  there are two cases to consider 1) the first
          *  occurrence of the median node is the first element in the
          *  sublist, i == 0, or 2) the first occurrence of the median node
          *  is somewhere in the sublist.
          */
         if (i == 0)
            walk_node = equal_head = equal_tail = low_node;
         else {
            equal_head = equal_tail = walk_node;
            equal_head->next->prev = equal_head->prev;
            equal_head->prev->next = equal_head->next;
            equal_head->next = low_node;
            walk_node = equal_head;
         }
         load_pivot( equal_head );

         /*
          * PARTITION:
          *  put all nodes less than the pivot on the end of the low list.
          *  put all nodes equal to the pivot on the end of the equal list.
          *  put all nodes greater than the pivot on the end of the high list.
          */
         for (count=low+1; count <= high; count++) {
            walk_node = walk_node->next;
            i = compare_pivot( walk_node );
            if (i > 0) {
               if (high_head == NULL)
                  high_head = high_tail = walk_node;
               else {
                  high_tail->next = walk_node;
                  walk_node->prev = high_tail;
                  high_tail = walk_node;
               }

               /*
                * keep a count of the number of nodes in the high list.
                */
               ++high_count;
            } else if (i < 0) {
               if (low_head == NULL)
                  low_head = low_tail = walk_node;
               else {
                  low_tail->next = walk_node;
                  walk_node->prev = low_tail;
                  low_tail = walk_node;
               }

               /*
                * keep a count of the number of nodes in the low list
                */
               ++low_count;
            } else {
               equal_tail->next = walk_node;
               walk_node->prev = equal_tail;
               equal_tail = walk_node;
            }
         }

         assert( low_count >= 0 );
         assert( low_count < high - low );
         assert( high_count >= 0 );
         assert( high_count < high - low );

         /*
          * we just partitioned the sublist into low, equal, and high
          *  sublists.  now, let's put the lists back together.
          */
         if (low_count > 0) {
            low_head->prev = low_start;
            if (low_start != NULL)
               low_start->next = low_head;
            else
               g_status.marked_file->line_list = low_head;
            low_tail->next = equal_head;
            equal_head->prev = low_tail;
         } else {
            equal_head->prev = low_start;
            if (low_start != NULL)
               low_start->next = equal_head;
            else
               g_status.marked_file->line_list = equal_head;
         }
         if (high_count > 0) {
            high_head->prev = equal_tail;
            equal_tail->next = high_head;
            high_tail->next = high_end;
            high_end->prev  = high_tail;
         } else {
            equal_tail->next = high_end;
            high_end->prev   = equal_tail;
         }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产另类av| 成人免费毛片片v| 欧美色图第一页| 国产精品国产三级国产普通话99 | 免费看欧美女人艹b| 99久久久久免费精品国产| 国产三级欧美三级日产三级99| 亚洲国产精品视频| 欧美四级电影在线观看| 中文字幕一区日韩精品欧美| 成人免费毛片aaaaa**| 久久伊99综合婷婷久久伊| 激情伊人五月天久久综合| 精品精品国产高清一毛片一天堂| 亚洲成人综合视频| 欧美一级精品大片| 久久爱www久久做| 国产亚洲精品资源在线26u| 婷婷久久综合九色综合绿巨人 | 欧美精品少妇一区二区三区| 午夜在线电影亚洲一区| 精品国产乱码久久久久久图片 | 久久99精品久久久久久国产越南| 日韩女优av电影| 丰满少妇久久久久久久| 国产精品久久久久aaaa樱花 | 国产亚洲欧美色| 国产91丝袜在线播放九色| 久久久久国产成人精品亚洲午夜| 激情综合色综合久久综合| www.欧美.com| 亚洲国产精品一区二区尤物区| 欧美美女网站色| 国产suv精品一区二区三区| 夜夜嗨av一区二区三区中文字幕 | 亚洲乱码日产精品bd| 4438x成人网最大色成网站| 国产不卡在线视频| 亚洲午夜电影网| 欧美激情中文不卡| 91精品欧美福利在线观看| 高潮精品一区videoshd| 蜜桃一区二区三区在线| 亚洲一区二区三区精品在线| 国产欧美精品一区二区色综合朱莉| 欧美日韩国产三级| voyeur盗摄精品| 丁香网亚洲国际| 国内偷窥港台综合视频在线播放| 综合婷婷亚洲小说| 欧美韩国日本不卡| 精品国产凹凸成av人网站| 欧美日韩国产综合一区二区三区| 成人av在线资源| 99久久久精品| 日本高清免费不卡视频| 色8久久人人97超碰香蕉987| 91视频观看视频| 91福利在线看| 欧美精品丝袜中出| 日韩欧美国产一区二区在线播放| 欧美中文字幕亚洲一区二区va在线| av电影天堂一区二区在线观看| 成人网在线免费视频| 成人不卡免费av| 欧美三级一区二区| 在线综合+亚洲+欧美中文字幕| 91精品国产综合久久精品麻豆| 欧美体内she精高潮| 欧美自拍偷拍一区| 欧美狂野另类xxxxoooo| 91麻豆精品91久久久久同性| 亚洲精品在线免费观看视频| 国产精品免费看片| 亚洲精品成人a在线观看| 日本美女一区二区三区| 国产精品资源网| 欧美亚洲一区二区在线观看| 日韩视频一区二区在线观看| 国产欧美一区二区精品仙草咪| 亚洲综合激情小说| 国产精品99久久久久| 欧美日韩高清一区| 欧美国产日韩a欧美在线观看| 亚洲色图在线视频| 美女高潮久久久| 在线视频你懂得一区| 精品国产一区二区三区久久影院| 一区二区三区四区av| a级高清视频欧美日韩| 欧美日韩精品三区| 最近中文字幕一区二区三区| 久久精品72免费观看| 91久久线看在观草草青青| 久久一二三国产| 老司机免费视频一区二区三区| 91麻豆免费看片| 中文字幕乱码日本亚洲一区二区| 日韩va亚洲va欧美va久久| 91国产丝袜在线播放| 亚洲天堂久久久久久久| 不卡的看片网站| 国产精品激情偷乱一区二区∴| 极品尤物av久久免费看| 日韩精品一区国产麻豆| 捆绑调教一区二区三区| 日韩一区和二区| 九色综合国产一区二区三区| 3d成人动漫网站| 裸体一区二区三区| 日韩欧美激情在线| 日本美女一区二区三区视频| 欧美一区二区三区系列电影| 日本中文在线一区| 久久欧美一区二区| 高清日韩电视剧大全免费| 国产精品毛片高清在线完整版| 成人av在线播放网站| 一区二区三区中文在线| 欧美一区二区网站| 国产真实乱对白精彩久久| 亚洲日本va在线观看| 欧美视频自拍偷拍| 精一区二区三区| 综合欧美亚洲日本| 欧美一区二区三区成人| zzijzzij亚洲日本少妇熟睡| 亚洲午夜激情av| 中文字幕一区二区5566日韩| 日韩视频免费观看高清完整版在线观看 | 亚洲综合激情网| 26uuu亚洲婷婷狠狠天堂| 色哟哟精品一区| 国产福利精品导航| 视频在线观看一区| 亚洲欧洲在线观看av| 精品久久国产97色综合| 色94色欧美sute亚洲线路一ni| 国产乱理伦片在线观看夜一区| 亚洲天堂网中文字| 日韩一区二区在线播放| 国产夫妻精品视频| 一区二区三区在线视频免费| 欧美精品一区二区三区在线| 色综合久久久久久久| 国产一区二区在线电影| 亚洲免费av观看| 欧美激情综合网| 久久综合色播五月| 7777精品伊人久久久大香线蕉的| 97久久超碰国产精品| 国产美女视频一区| 亚洲在线中文字幕| 亚洲精品一区二区三区在线观看| 在线日韩国产精品| av电影天堂一区二区在线观看| 韩国三级在线一区| 日韩二区三区在线观看| 一区二区三区欧美日韩| 综合激情成人伊人| 欧美日韩国产精品成人| 欧美色窝79yyyycom| 一道本成人在线| 色网综合在线观看| 色欧美日韩亚洲| 色综合色综合色综合色综合色综合 | 亚洲一区视频在线| 亚洲男女一区二区三区| 亚洲精品ww久久久久久p站 | 欧美日韩二区三区| 91精品国产综合久久福利 | 久久精品亚洲精品国产欧美 | 99综合电影在线视频| 色婷婷综合久久久中文一区二区| 在线亚洲精品福利网址导航| 欧美三级日韩在线| 欧美乱熟臀69xxxxxx| 欧美一区二区在线播放| 国产精品私人影院| 亚洲精品视频一区| 久久精品噜噜噜成人88aⅴ | 欧美xxxxxxxxx| 一区二区三区精品久久久| 亚洲综合成人网| 久久99国产精品久久| 一本大道综合伊人精品热热| 在线成人免费观看| 国产片一区二区三区| 亚洲精品乱码久久久久久| 亚洲高清在线精品| 国产东北露脸精品视频| 欧美在线看片a免费观看| 中文字幕欧美三区| 国产精品久久久久影院| 亚洲精品老司机| 成人激情黄色小说| 欧美一区二区在线观看| 一区二区视频在线| 国产真实乱子伦精品视频| 欧美一级二级在线观看|