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

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

?? sort.c

?? C語(yǔ)言實(shí)戰(zhàn)105例源碼
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):

#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;
         }

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜影视日本亚洲欧洲精品| 悠悠色在线精品| 亚洲国产精品一区二区www在线| 国模大尺度一区二区三区| 在线观看中文字幕不卡| 国产亚洲精品超碰| 青青草视频一区| 欧美色图12p| 亚洲欧美在线视频观看| 国产一区二区电影| 欧美成人女星排行榜| 一区二区三区国产精品| fc2成人免费人成在线观看播放| 日韩精品一区二区三区swag| 亚洲一区影音先锋| 91麻豆高清视频| 日本一区二区三区久久久久久久久不| 日韩电影在线一区二区三区| 色94色欧美sute亚洲线路二| 国产精品传媒入口麻豆| 国产精品99久久久久久久vr| 欧美成人福利视频| 天堂午夜影视日韩欧美一区二区| 色呦呦国产精品| 国产精品国产a| 成人a区在线观看| 中文字幕欧美激情| 国产高清在线精品| 久久精品男人的天堂| 精品影视av免费| 欧美大片在线观看一区| 男男成人高潮片免费网站| 51精品视频一区二区三区| 亚洲国产日韩a在线播放| 欧洲在线/亚洲| 亚洲在线观看免费| 欧美色老头old∨ideo| 亚洲成a人片在线不卡一二三区| 欧美做爰猛烈大尺度电影无法无天| 日韩毛片一二三区| 91麻豆高清视频| 亚洲午夜精品在线| 欧美日韩精品专区| 天天操天天色综合| 日韩一区国产二区欧美三区| 男人的天堂久久精品| 精品国产欧美一区二区| 韩日精品视频一区| 久久久精品tv| 成人黄动漫网站免费app| 国产精品久久久久aaaa| 91色在线porny| 亚洲一区二区三区四区在线观看| 欧美日韩免费高清一区色橹橹 | 欧美午夜精品一区二区三区| 一区二区在线观看视频| 在线这里只有精品| 天天影视色香欲综合网老头| 欧美电视剧免费观看| 国产精品1024久久| 最新中文字幕一区二区三区 | 国产一区二区电影| 欧美韩国日本综合| 91国产福利在线| 丝袜亚洲精品中文字幕一区| 日韩精品一区二区在线| 懂色av一区二区三区免费观看| 中文字幕日韩av资源站| 欧美日韩激情一区二区三区| 免费视频一区二区| 久久久噜噜噜久久中文字幕色伊伊| 成人黄色网址在线观看| 亚洲一二三四区| 欧美大片在线观看一区二区| 成a人片亚洲日本久久| 性做久久久久久免费观看欧美| 欧美成人女星排行榜| 成人精品视频一区二区三区| 亚洲成人高清在线| 日韩欧美不卡一区| 91视视频在线直接观看在线看网页在线看 | 成人18精品视频| 首页欧美精品中文字幕| 国产日产欧美一区二区三区| 色网综合在线观看| 美腿丝袜亚洲色图| 亚洲欧洲韩国日本视频| 3atv一区二区三区| 国产a精品视频| 亚洲国产aⅴ成人精品无吗| 精品三级av在线| 一本色道**综合亚洲精品蜜桃冫| 久久精品国产第一区二区三区| 国产精品国产成人国产三级| 欧美一区二区三区在线看| www.在线欧美| 日韩成人精品在线| 一区在线观看视频| 日韩视频免费直播| 日本久久电影网| 国内精品久久久久影院薰衣草| 一区二区三区在线免费视频| 精品不卡在线视频| 欧美三级电影一区| 国产69精品一区二区亚洲孕妇| 午夜精品福利一区二区蜜股av| 国产日韩欧美激情| 欧美一区二区三区思思人| 91片在线免费观看| 国产剧情一区在线| 日韩精品一级二级| 一区二区三区不卡在线观看 | 久久精品亚洲麻豆av一区二区| 欧美日韩日本视频| 91麻豆国产福利精品| 国产成人啪午夜精品网站男同| 婷婷亚洲久悠悠色悠在线播放| 亚洲日本中文字幕区| 久久综合九色综合久久久精品综合| 欧美视频一区二区| 91在线你懂得| 国产成人综合在线观看| 麻豆成人久久精品二区三区小说| 亚洲精品v日韩精品| 国产精品色呦呦| 久久先锋影音av鲁色资源网| 91精品国产综合久久香蕉的特点 | 97se亚洲国产综合在线| 国产乱子伦视频一区二区三区| 日韩有码一区二区三区| 亚洲午夜在线观看视频在线| 日韩美女视频19| 国产精品日产欧美久久久久| 久久一区二区三区四区| 日韩欧美一级二级| 制服.丝袜.亚洲.另类.中文| 精品视频一区 二区 三区| 色综合一区二区| 99久久久国产精品免费蜜臀| 风间由美性色一区二区三区| 国产在线一区观看| 韩日av一区二区| 精品一区二区在线视频| 免费久久99精品国产| 性久久久久久久久久久久| 亚洲第一激情av| 亚洲国产美国国产综合一区二区| 亚洲欧美日韩电影| 亚洲男人天堂一区| 亚洲乱码国产乱码精品精可以看| 日韩一区欧美一区| 亚洲天堂精品视频| 18成人在线观看| 亚洲精品高清视频在线观看| 亚洲另类一区二区| 一区二区三区在线观看国产| 一区二区三区av电影| 亚洲影视在线播放| 午夜影院久久久| 奇米777欧美一区二区| 蜜臀av性久久久久蜜臀av麻豆| 老司机精品视频线观看86| 麻豆成人91精品二区三区| 精品影视av免费| 国产99久久久精品| av在线综合网| 在线视频观看一区| 欧美日韩国产影片| 日韩一级片在线播放| 欧美岛国在线观看| 欧美—级在线免费片| 亚洲视频在线一区二区| 亚洲午夜在线视频| 日韩电影免费在线观看网站| 精品一区二区三区免费| 成人午夜激情在线| 色呦呦网站一区| 91精品国产美女浴室洗澡无遮挡| 日韩欧美黄色影院| 久久久久久97三级| 日韩久久一区二区| 亚洲电影视频在线| 久久机这里只有精品| 国产精品69毛片高清亚洲| 成人高清免费观看| 欧美性做爰猛烈叫床潮| 日韩视频一区在线观看| 国产欧美一区二区三区沐欲| 亚洲欧美日本韩国| 日本伊人色综合网| 国产高清亚洲一区| 欧美制服丝袜第一页| 精品免费日韩av| 一区免费观看视频| 日本不卡不码高清免费观看| 国产成人免费av在线| 欧美在线观看18| 亚洲精品在线观看网站| 中文字幕亚洲精品在线观看| 日韩精品一级中文字幕精品视频免费观看|