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

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

?? sort.c

?? c 語言學習220例
?? 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;
         }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
9i看片成人免费高清| 一区二区三区四区不卡视频| 亚洲va中文字幕| 91福利小视频| 午夜欧美视频在线观看| 欧美这里有精品| 亚洲国产aⅴ成人精品无吗| 91久久精品一区二区| 亚洲综合丝袜美腿| 欧美日韩高清一区二区三区| 日韩高清在线一区| 日韩欧美另类在线| 国产麻豆一精品一av一免费| 久久精品视频免费| 99re热视频精品| 一区二区三区色| 欧美精品丝袜中出| 毛片一区二区三区| 国产欧美一区二区精品性| 成人av网站免费观看| 一区二区三区蜜桃| 在线电影国产精品| 精品在线亚洲视频| 欧美极品美女视频| 欧美无乱码久久久免费午夜一区| 日韩专区中文字幕一区二区| 欧美精品一区二| 99久久777色| 日韩精品乱码免费| 欧美va亚洲va| 91色乱码一区二区三区| 欧美精品一区二区不卡| 青青草国产成人99久久| 成人免费视频国产在线观看| 国产91色综合久久免费分享| 国产成人精品影视| 色哟哟在线观看一区二区三区| 欧美精品一区二区三区视频| 人人狠狠综合久久亚洲| 精品亚洲porn| www.成人网.com| 日韩一区二区不卡| 秋霞影院一区二区| 欧美视频日韩视频在线观看| 欧美日韩国产综合视频在线观看| av网站免费线看精品| 久久久国产一区二区三区四区小说| 亚洲免费在线播放| 成人亚洲精品久久久久软件| 国产精品你懂的在线欣赏| 国产激情一区二区三区四区| 久久久国产精华| 成人动漫一区二区三区| 亚洲同性gay激情无套| 一本大道久久a久久综合婷婷| 亚洲婷婷国产精品电影人久久| 色欧美片视频在线观看在线视频| 亚洲国产另类av| 678五月天丁香亚洲综合网| 一区二区三区日韩欧美| 日韩欧美的一区| 成人激情小说乱人伦| 亚洲国产中文字幕在线视频综合| 欧美人妖巨大在线| 成人免费看黄yyy456| 日本欧美一区二区三区| 中文字幕一区二区视频| 欧美mv日韩mv亚洲| 欧美日韩日本视频| 日韩精品亚洲一区| 亚洲国产激情av| 久久这里只有精品6| 欧美三级韩国三级日本一级| 国产精品一区二区三区四区| 亚洲成av人**亚洲成av**| xvideos.蜜桃一区二区| 欧美三级视频在线播放| 国精产品一区一区三区mba桃花 | 国产精品一二三| 日韩欧美高清dvd碟片| 欧美在线不卡一区| 国产成人在线观看| 国产精品自拍av| 国产永久精品大片wwwapp| 制服视频三区第一页精品| 国产主播一区二区三区| 亚洲欧洲三级电影| 日韩午夜精品视频| 欧美日韩一级片网站| 91小视频在线| 欧美三级日韩在线| 精品国产网站在线观看| 国产精品福利一区二区| 视频一区二区三区在线| 亚洲午夜电影网| 国产激情一区二区三区四区 | 成人一级视频在线观看| 不卡的av电影| 在线电影院国产精品| 国产日产精品一区| 亚洲国产aⅴ成人精品无吗| 亚洲777理论| 国产传媒一区在线| 在线观看av一区二区| 欧美电影免费观看高清完整版| 久久久精品国产免大香伊| 亚洲欧洲一区二区在线播放| 视频一区中文字幕| 欧美日韩在线三级| 国产精品久久久久三级| 亚洲精品自拍动漫在线| 久久精品72免费观看| 成人午夜视频免费看| 欧美日韩一级视频| 国产三级精品三级在线专区| 亚洲国产日韩精品| 国产成人免费视频网站| 欧美成人猛片aaaaaaa| 天天色图综合网| 911精品产国品一二三产区| 国产精品理伦片| 国产成人精品1024| 国产亚洲欧洲997久久综合| 五月综合激情婷婷六月色窝| 欧美日韩国产三级| 亚洲精品国产a| 色美美综合视频| 日韩欧美电影一区| 日日摸夜夜添夜夜添亚洲女人| 日韩一级二级三级| 国产成人精品免费视频网站| 亚洲女同一区二区| 成人激情黄色小说| 欧美亚洲高清一区二区三区不卡| 亚洲美女区一区| 欧美丰满少妇xxxxx高潮对白| 美女视频黄免费的久久| 精品va天堂亚洲国产| 岛国av在线一区| 亚洲婷婷国产精品电影人久久| 欧美三级乱人伦电影| 日本不卡免费在线视频| 日韩午夜在线观看视频| 成人免费高清视频| 亚洲综合久久av| 日韩欧美国产一区在线观看| 99精品视频在线免费观看| 日韩免费成人网| 在线观看国产精品网站| 白白色 亚洲乱淫| 成人福利视频在线看| 丁香亚洲综合激情啪啪综合| 国产呦精品一区二区三区网站| 精品一区二区影视| 久久av老司机精品网站导航| 日韩精品乱码免费| 午夜av电影一区| 日本不卡123| 老司机免费视频一区二区| 蜜臀va亚洲va欧美va天堂| 青青草成人在线观看| 亚洲国产欧美在线| 国产精品第五页| 国产精品福利电影一区二区三区四区| 日韩欧美一区二区久久婷婷| 欧美三区免费完整视频在线观看| 99久久99久久精品免费看蜜桃| 东方aⅴ免费观看久久av| 精品中文av资源站在线观看| 日韩av在线播放中文字幕| 天天色综合天天| 蜜桃一区二区三区在线| 日本一不卡视频| 国产电影一区在线| 色天使色偷偷av一区二区| 中文字幕一区二区三区四区不卡| 国产精品久久久久久久裸模| 亚洲欧美激情一区二区| 日本vs亚洲vs韩国一区三区二区| 蜜桃一区二区三区在线观看| 国产高清不卡二三区| 美脚の诱脚舐め脚责91| 亚洲一区二区三区不卡国产欧美| 国产精品色婷婷| 国产精品视频你懂的| 中文字幕第一区二区| 国产精品每日更新| 日韩一区在线看| 亚洲一区二区三区四区在线免费观看 | 久久亚洲精品国产精品紫薇| 日韩色视频在线观看| 久久精品视频免费| 亚洲男人的天堂在线观看| 亚洲韩国精品一区| 久久国产综合精品| 国产suv一区二区三区88区| 色综合一区二区三区| 4438亚洲最大| 国产精品视频麻豆| 亚洲一区视频在线|