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

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

?? strlist.c

?? 信息檢索中常用的技術
?? C
字號:
/*******************************   strlist.c   *********************************    Purpose: String list abstract data type implementation.    Notes:   This module implements a straightforward string ordered list             abstract data type.  It is optimized for appending and deleting             from the end of the list.  Since they are ordered lists, string             lists may be sorted, and their members are addressed by ordinal             position (starting from 0).**/#include <stdio.h>#include <memory.h>#include <malloc.h>#include <string.h>#include "strlist.h"/******************************************************************************//******************   Private Defines and Data Structures   *******************/#define FALSE                          0#define TRUE                           1#define EOS                          '\0'#define INCREMENT                     32    /* increase size by this much */#define MAX_LINE                     128    /* when reading text files */typedef struct _StrListStruct {               short size;             /* current length of the list */               short max_size;         /* room for this many strings */               char **string;          /* the string array */               } StrListStruct;            /*********   GetMemory and FreeMemory Macros   ********/#define GetMemory(b,s)                ( (b) ? realloc(b,s) : malloc(s) )#define FreeMemory(b)                 ( (void)free( b ) )/******************************************************************************//**********************   Private Routine Declarations   **********************/#ifdef __STDC__static int  ExpandArray( StrList list );static void ISort( char **string, int lb, int ub );static void QSort( char **string, int lb, int ub );#elsestatic int  ExpandArray( /* list */ );static void ISort( /* string, lb, ub */ );static void QSort( /* string, lb, ub */ );#endif/*FN**************************************************************************         ExpandArray( list )   Returns: int -- TRUE (1) on success, FALSE (0) otherwise   Purpose: Increase the string array to hold more data   Plan:    Part 1: Increase the maximum list size to its new value            Part 2: Allocate a new chunk of memory            Part 3: Return an indication of success   Notes:   None**/static intExpandArray( list )   StrList list;   /* in: string list whose string array is enlarged */   {         /* Part 1: Increase the maximum list size to its new value */   list->max_size += INCREMENT;                  /* Part 2: Allocate a new chunk of memory */   list->string = (char **)GetMemory( (char *)list->string,                                      (list->max_size*sizeof(char *)) );                 /* Part 3: Return an indication of success */   return( (list->string) ? TRUE : FALSE );   } /* ExpandArray *//*FN**************************************************************************         ISort( string, lb, ub )   Returns: void   Purpose: Insertion sort a string array forward using strcmp ordering   Plan:    Part 1: Put smallest in place as a sentinal            Part 2: Insert as necessary   Notes:   None**/static voidISort( string, lb, ub )   char **string;   /* in-out: string array sorted */   int lb, ub;       /* in: array bounds for sort */   {   register int i,j;  /* for scanning through the list */   char *tmp;         /* for swaps */               /* Part 1: Put smallest in place as a sentinal */   for ( j = lb, i = lb+1; i <= ub; i++ )      if ( 0 < strcmp(string[j],string[i]) ) j = i;   tmp = string[lb]; string[lb] = string[j]; string[j] = tmp;                       /* Part 2: Insert as necessary */   for ( i = lb+2; i <= ub; i++ )      {      tmp = string[i];      for ( j = i; 0 < strcmp(string[j-1],tmp); j-- ) string[j] = string[j-1];      string[j] = tmp;      }   } /* ISort*//*FN**************************************************************************         QSort( string, lb, ub )   Returns: void   Purpose: Quicksort an array of strings forward using strcmp ordering   Plan:    Part 1: Use insertion sort of the list is short            Part 2: Do median of three pivot value selection            Part 3: Put the pivot out of the way at the top            Part 5: Swap the pivot back into the mid of the list            Part 6: Recursively sort the sublists   Notes:   Standard quicksort function with the two main enhancements:            median of three partitioning to find a good pivot value,            and sorting small arrays with insertion sort.**/static voidQSort( string, lb, ub )   char **string;  /* in/out: string array sorted */   int lb,ub;      /* in: array bounds for sort */   {   register int lft;  /* list pointer that closes from the left */   register int rgt;  /* list pointer that closes from the right */   register int mid;  /* index of the median of three value */   char *tmp;         /* for string pointer swaps */   char *pivot;       /* the pivot value string */              /* Part 1: Use insertion sort of the list is short */   if ( ub-lb < 12 ) { ISort( string, lb, ub ); return; }             /* Part 2: Do median of three pivot value selection */   mid = (lb+ub)/2;   if ( strcmp(string[mid],string[lb]) < 0 )      { tmp = string[mid]; string[mid] = string[lb]; string[lb] = tmp; }   if ( strcmp(string[ub],string[mid]) < 0 )      { tmp = string[mid]; string[mid] = string[ub]; string[ub] = tmp; }   if ( strcmp(string[mid],string[lb]) < 0 )      { tmp = string[mid]; string[mid] = string[lb]; string[lb] = tmp; }             /* Part 3: Put the pivot out of the way at the top */   tmp = string[mid]; string[mid] = string[ub-1]; string[ub-1] = tmp;                 /* Part 4: Partition around the pivot value */   lft = lb;   rgt = ub-1;   pivot = string[ub-1];   do      {      do lft++; while ( strcmp(string[lft],pivot) < 0 );      do rgt--; while ( strcmp(pivot,string[rgt]) < 0 );      tmp = string[lft]; string[lft] = string[rgt]; string[rgt] = tmp;      }   while ( lft < rgt );         /* Part 5: Swap the pivot back into the mid of the list */   string[rgt] = string[lft]; string[lft] = string[ub-1]; string[ub-1] = tmp;                  /* Part 6: Recursively sort the sublists */   QSort( string, lb, lft-1 );   QSort( string, rgt+1, ub );   } /* QSort *//******************************************************************************//**********************   Public Routine Declarations   ***********************//*FN***************************************************************************         StrListAppend( list, string )   Returns: void   Purpose: Place a string on the end of a string list   Plan:    Part 1: Standard parameter sanity check            Part 2: Expand the list as necessary            Part 3: Append the new string to the tail   Notes:   None**/voidStrListAppend( list, string )   StrList list;   /* in/out: list appended to */   char *string;   /* in: the appended string */   {   int length;  /* of the added string and its terminator */                 /* Part 1: Standard parameter sanity check */   if ( !list || !string ) return;                   /* Part 2: Expand the list as necessary */   if ( (list->size == list->max_size) && !ExpandArray(list) ) return;                 /* Part 3: Append the new string to the tail */   length = strlen( string ) + 1;   list->string[list->size] = GetMemory( NULL, length );   (void)memcpy( list->string[list->size], string, length );   list->size++;   } /* StrListAppend *//*FN***************************************************************************         StrListAppendFile( list, filename )   Returns: void   Purpose: Place all lines from a file on the end of a string list   Plan:    Part 1: Standard parameter sanity check            Part 2: Expand the list as necessary            Part 3: Append the new string to the tail   Notes:   None**/voidStrListAppendFile( list, filename )   StrList list;     /* in/out: list appended to */   char *filename;   /* in: the appended file */   {   FILE *file;            /* file handle for the text input file */   char buffer[MAX_LINE]; /* for storing text input file lines */   int length;            /* of the added string and its terminator */   register int i;        /* for looping through the TextBlock lines */                 /* Part 1: Standard parameter sanity check */   if ( !list || !filename ) return;             /* Part 2: Open the text input file; check for error */   if ( NULL == (file = fopen(filename,"r")) ) return;              /* Part 3: Append to the list, checking for errors */   while ( NULL != fgets(buffer,MAX_LINE,file) )      {      if ( (list->size == list->max_size) && !ExpandArray(list) ) return;      i = list->size;      length = strlen( buffer );      list->string[i] = GetMemory( NULL, (unsigned)length );      if ( NULL == list->string[i] ) return;      (void)memcpy( list->string[i], buffer, length );      list->string[i][length-1] = EOS;      list->size++;      }                    /* Part 4: Close the text input file */   (void)fclose( file );   } /* StrListAppendFile *//*FN***************************************************************************         StrListCreate()   Returns: StrList -- a new structure, or NULL on failure   Purpose: Allocate and initialize a new string list structure   Plan:    Part 1: Allocate space for the string list object            Part 2: Initialize the structure fields            Part 3: Return the new string list   Notes:   None**/StrListStrListCreate()   {   StrList list;  /* the new list returned */            /* Part 1: Allocate space for the string list object */   if ( !(list = (StrList)GetMemory(NULL,sizeof(StrListStruct))) )      return( NULL );                 /* Part 2: Initialize the structure fields */   list->string = NULL;   list->size = list->max_size = 0;   if ( !ExpandArray(list) )      { FreeMemory( (char *)list ); return( NULL ); }                    /* Part 3: Return the new string list */   return( list );   } /* StrListCreate *//*FN***************************************************************************         StrListDestroy( list )   Returns: void   Purpose: Deallocate the space used for a string list   Plan:    Part 1: Standard parameter sanity check            Part 2: Free all the space   Notes:   None**/voidStrListDestroy( list )   StrList list;    /* in: the list destroyed */   {   register int i;  /* for scanning through the list */                 /* Part 1: Standard parameter sanity check */   if ( !list ) return;                        /* Part 2: Free all the space */   for ( i = 0; i < list->size; i++ ) FreeMemory( (char *)(list->string[i]) );   FreeMemory( (char *)list );   } /* StrListDestroy *//*FN***************************************************************************         StrListEqual( list1, list2 )   Returns: int -- TRUE if the lists are equivalent, FALSE otherwise   Purpose: See if two lists have identical elements   Plan:    Part 1: Say not equal if the parameters are bad            Part 2: Say not equal if sizes are different            Part 3: Compare lists element by element            Part 4: Say equal if everything checks out   Notes:   None**/intStrListEqual( list1, list2 )   StrList list1,list2;   /* in: lists compared */   {   register int i;  /* for scanning through the lists */             /* Part 1: Say not equal if the parameters are bad */   if ( !list1 || !list2 ) return( FALSE );               /* Part 2: Say not equal if sizes are different */   if ( list1->size != list2->size ) return( FALSE );              /* Part 3: Compare the lists element by element */   for ( i = 0; i < list1->size; i++ )      if ( *(list1->string[i]) != *(list2->string[i]) )         return( FALSE );      else if ( 0 != strcmp(list1->string[i],list2->string[i]) )         return( FALSE );               /* Part 5: Say equal if everything checks out */   return( TRUE );   } /* StrListEqual *//*FN***************************************************************************         StrListPeek( list, index )   Returns: char * -- pointer to the requested string; NULL on error   Purpose: Peek a string by its list index   Plan:    Part 1: Standard parameter sanity check            Part 2: Return the requested string   Notes:   Note that this function is a hole in the data type encapsulation:            it should return a copy, but this would force the consumer to            deallocate the string.  Design call.**/char *StrListPeek( list, index )   StrList list;   /* in: list retrieved from */   int index;      /* in: which string to fetch */   {                 /* Part 1: Standard parameter sanity check */   if ( !list || (index < 0) || (list->size <= index) ) return( NULL );                   /* Part 2: Return the requested string */   return( list->string[index] );   } /* StrListPeek *//*FN***************************************************************************         StrListSize( list )   Returns: int -- the size of the list, 0 on error   Purpose: Grab the list size   Plan:    Return the list size field   Notes:   None**/intStrListSize( list )   StrList list;   /* in: list queried */   {   if ( !list ) return( 0 ); else return( list->size );   } /* StrListSize *//*FN***************************************************************************         StrListSort( list )   Returns: void   Purpose: Sort a single string list using strcmp ordering   Plan:    Part 1: Do parameter sanity checks, then sort   Notes:   None**/voidStrListSort( list )   StrList list;   /* in/out: list sorted */   {             /* Part 1: Do parameter sanity checks, then sort */   if ( !list ) return;   QSort( list->string, 0, list->size-1 );   } /* StrListSort *//*FN***************************************************************************         StrListUnique( list )   Returns: void   Purpose: Sort a single string list using strcmp ordering, then remove            duplicates.   Plan:    Part 1: Do parameters sanity checks            Part 2: Sort the list            Part 3: Remove duplicate strings   Notes:   None**/voidStrListUnique( list )   StrList list;   /* in/out: list sorted and uniqued */   {   register i,j;   /* counters for copying down over duplicates */                    /* Part 1: Do parameter sanity checks */   if ( !list ) return;                       /* Part 2: Sort the list */   QSort( list->string, 0, list->size-1 );                   /* Part 3: Remove duplicate strings */   if ( 1 < list->size )      {      for ( j = 0, i = 1; i < list->size; i++ )         {         if ( 0 == strcmp(list->string[i],list->string[j]) )            (void)free( list->string[j] );         else            j++;         if ( j < i ) list->string[j] = list->string[i];         }      list->size = j + 1;      }   } /* StrListUnique */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人免费的视频| 国产精品不卡在线| 91污在线观看| 精品一区二区免费在线观看| 韩国一区二区三区| 日韩成人av影视| 亚洲一区二区综合| 一本久道久久综合中文字幕 | 国产精品久久久久久久久果冻传媒| 日韩欧美国产系列| 欧美zozo另类异族| 欧美xxxxxxxxx| 久久久久久久久蜜桃| 久久免费电影网| 日本一区二区三区在线不卡| 国产日韩欧美高清| 国产精品无人区| 国产精品久久久久久久久动漫| 国产精品国产三级国产a| 国产精品九色蝌蚪自拍| 专区另类欧美日韩| 亚洲一区二区三区爽爽爽爽爽| 亚洲成人精品一区| 蜜臀av性久久久久蜜臀av麻豆| 精品一区二区在线观看| 国产成人8x视频一区二区| 丁香婷婷综合网| av一区二区三区在线| 色欧美日韩亚洲| 成人精品高清在线| 成人一区二区三区中文字幕| 成人精品gif动图一区| 国产美女主播视频一区| 粉嫩av一区二区三区| 91在线视频播放| 欧美吞精做爰啪啪高潮| 欧美日韩国产在线观看| 日韩一级完整毛片| 日韩免费看网站| 中文字幕免费观看一区| 亚洲色图在线播放| 亚洲成人精品一区二区| 久久国产生活片100| 国产成人午夜高潮毛片| 波多野结衣亚洲| 欧美在线视频不卡| 欧美一级国产精品| 国产欧美一区二区精品久导航| 国产精品伦一区| 亚洲五码中文字幕| 极品少妇一区二区| 成人黄色综合网站| 欧美人与禽zozo性伦| 久久久蜜桃精品| 亚洲美女偷拍久久| 蜜桃av一区二区三区电影| 久久电影网电视剧免费观看| 美国三级日本三级久久99| 色综合网站在线| 欧美一区二区三区在线视频| 欧美成人伊人久久综合网| 国产精品视频你懂的| 中文字幕人成不卡一区| 天天做天天摸天天爽国产一区| 免费精品视频在线| 波多野结衣中文字幕一区二区三区| 欧美亚洲综合在线| 国产三级欧美三级日产三级99| 一区二区三区在线免费播放| 精品一区二区在线看| 91免费观看在线| 2023国产精品| 亚洲国产毛片aaaaa无费看| 国产精品自拍三区| 欧美精品一二三区| 欧美激情一区在线观看| 日日夜夜免费精品视频| voyeur盗摄精品| 欧美一区二区三区视频| 亚洲三级在线免费| 国产综合色在线视频区| 欧美三区免费完整视频在线观看| 久久久99免费| 秋霞av亚洲一区二区三| 91色九色蝌蚪| 国产日韩欧美激情| 免费观看日韩av| 在线视频欧美区| 久久综合狠狠综合久久综合88 | 懂色一区二区三区免费观看| 91精品国产综合久久精品麻豆| 亚洲另类一区二区| 国产成人午夜精品影院观看视频 | 亚洲欧美偷拍三级| 国产麻豆精品视频| 日韩欧美色电影| 亚洲国产精品自拍| 91日韩一区二区三区| 亚洲国产高清aⅴ视频| 久久精品国产澳门| 欧美妇女性影城| 成人免费一区二区三区视频 | 一级精品视频在线观看宜春院| 国产乱色国产精品免费视频| 日韩一区二区三区免费观看 | eeuss影院一区二区三区| 久久免费国产精品| 精品一区二区三区久久| 91久久精品一区二区三区| 亚洲免费在线视频一区 二区| 成人aa视频在线观看| 国产精品免费视频网站| 国产不卡在线播放| 久久久久久麻豆| 国产精品一二三四| 久久久蜜桃精品| 国产999精品久久久久久绿帽| 久久久国产精品麻豆| 国产精品香蕉一区二区三区| 日韩欧美中文字幕精品| 偷拍自拍另类欧美| 在线不卡一区二区| 蜜臂av日日欢夜夜爽一区| 7777精品伊人久久久大香线蕉超级流畅 | 欧美日韩成人在线| 国产精品网曝门| 国产成人综合亚洲网站| 久久久五月婷婷| 福利一区二区在线| 国产精品麻豆视频| 国产精品996| 国产精品污网站| 91麻豆福利精品推荐| 一区二区三区免费看视频| 色综合欧美在线视频区| 一区二区三区在线影院| 欧美日韩精品三区| 日本在线不卡一区| 精品国产精品网麻豆系列| 一区二区高清在线| 97精品久久久午夜一区二区三区| 中文字幕av一区二区三区高| 不卡的电视剧免费网站有什么| **网站欧美大片在线观看| 一本大道av一区二区在线播放| 午夜欧美视频在线观看| 日韩欧美在线影院| 国产福利精品一区| 亚洲精品中文在线| 在线区一区二视频| 秋霞午夜av一区二区三区| 91在线免费播放| 性感美女极品91精品| 精品久久人人做人人爽| 成人免费av资源| 亚洲一区二区三区四区在线| 日韩一级完整毛片| 狠狠网亚洲精品| 亚洲免费观看高清完整版在线观看| 欧美日韩视频在线一区二区| 国产专区欧美精品| 亚洲女与黑人做爰| 欧美日韩精品电影| 国产一区二区三区在线看麻豆| 国产精品色呦呦| 一本一道久久a久久精品| 日韩国产欧美在线观看| 国产视频亚洲色图| 色香蕉久久蜜桃| 韩国三级电影一区二区| 亚洲裸体在线观看| 欧美电影免费观看完整版| 蜜桃视频在线观看一区| 亚洲人xxxx| 26uuuu精品一区二区| 欧美亚洲国产一区二区三区va| 国产综合久久久久久鬼色| 亚洲男人的天堂一区二区| 久久综合久久久久88| 99re视频精品| 久久99国产精品麻豆| 最新不卡av在线| 精品欧美一区二区三区精品久久| 日本韩国一区二区三区| 国产一区二区电影| 日韩二区三区在线观看| 亚洲免费看黄网站| 久久久99精品久久| 欧美区在线观看| 一本高清dvd不卡在线观看| 国产精品亚洲午夜一区二区三区| 亚洲成人自拍偷拍| 中文字幕一区二区视频| 精品国精品国产尤物美女| 99re热这里只有精品免费视频| 激情五月婷婷综合| 日韩av中文字幕一区二区| 国产精品免费aⅴ片在线观看| 欧美日韩aaaaa| 日本韩国一区二区三区|