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

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

?? hash.c

?? 哈希表實現
?? C
字號:
/* +++Date last modified: 05-Jul-1997 */#include <string.h>#include <stdlib.h>#include "hash.h"/*** public domain code by Jerry Coffin, with improvements by HenkJan Wolthuis.**** Tested with Visual C 1.0 and Borland C 3.1.** Compiles without warnings, and seems like it should be pretty** portable.*//*** These are used in freeing a table.  Perhaps I should code up** something a little less grungy, but it works, so what the heck.*/static void (*function)(void *) = (void (*)(void *))NULL;static hash_table *the_table = NULL;/* Initialize the hash_table to the size asked for.  Allocates space** for the correct number of pointers and sets them to NULL.  If it** can't allocate sufficient memory, signals error by setting the size** of the table to 0.*/hash_table *construct_table(hash_table *table, size_t size){      size_t i;      bucket **temp;      table -> size  = size;      table -> table = (bucket * *)malloc(sizeof(bucket *) * size);      temp = table -> table;      if ( temp == NULL )      {            table -> size = 0;            return table;      }      for (i=0;i<size;i++)            temp[i] = NULL;      return table;}/*** Hashes a string to produce an unsigned short, which should be** sufficient for most purposes.*/static unsigned hash(char *string){      unsigned ret_val = 0;      int i;      while (*string)      {            i = *( int *)string;            ret_val ^= i;            ret_val <<= 1;            string ++;      }      return ret_val;}/*** Insert 'key' into hash table.** Returns pointer to old data associated with the key, if any, or** NULL if the key wasn't in the table previously.*/void *insert(char *key, void *data, hash_table *table){      unsigned val = hash(key) % table->size;      bucket *ptr;      /*      ** NULL means this bucket hasn't been used yet.  We'll simply      ** allocate space for our new bucket and put our data there, with      ** the table pointing at it.      */      if (NULL == (table->table)[val])      {            (table->table)[val] = (bucket *)malloc(sizeof(bucket));            if (NULL==(table->table)[val])                  return NULL;            (table->table)[val] -> key = strdup(key);            (table->table)[val] -> next = NULL;            (table->table)[val] -> data = data;            return (table->table)[val] -> data;      }      /*      ** This spot in the table is already in use.  See if the current string      ** has already been inserted, and if so, increment its count.      */      for (ptr = (table->table)[val];NULL != ptr; ptr = ptr -> next)            if (0 == strcmp(key, ptr->key))            {                  void *old_data;                  old_data = ptr->data;                  ptr -> data = data;                  return old_data;            }      /*      ** This key must not be in the table yet.  We'll add it to the head of      ** the list at this spot in the hash table.  Speed would be      ** slightly improved if the list was kept sorted instead.  In this case,      ** this code would be moved into the loop above, and the insertion would      ** take place as soon as it was determined that the present key in the      ** list was larger than this one.      */      ptr = (bucket *)malloc(sizeof(bucket));      if (NULL==ptr)            return 0;      ptr -> key = strdup(key);      ptr -> data = data;      ptr -> next = (table->table)[val];      (table->table)[val] = ptr;      return data;}/*** Look up a key and return the associated data.  Returns NULL if** the key is not in the table.*/void *lookup(char *key, hash_table *table){      unsigned val = hash(key) % table->size;      bucket *ptr;      if (NULL == (table->table)[val])            return NULL;      for ( ptr = (table->table)[val];NULL != ptr; ptr = ptr->next )      {            if (0 == strcmp(key, ptr -> key ) )                  return ptr->data;      }      return NULL;}/*** Delete a key from the hash table and return associated** data, or NULL if not present.*/void *del(char *key, hash_table *table){      unsigned val = hash(key) % table->size;      void *data;      bucket *ptr, *last = NULL;      if (NULL == (table->table)[val])            return NULL;      /*      ** Traverse the list, keeping track of the previous node in the list.      ** When we find the node to delete, we set the previous node's next      ** pointer to point to the node after ourself instead.  We then delete      ** the key from the present node, and return a pointer to the data it      ** contains.      */      for (last = NULL, ptr = (table->table)[val];            NULL != ptr;            last = ptr, ptr = ptr->next)      {            if (0 == strcmp(key, ptr -> key))            {                  if (last != NULL )                  {                        data = ptr -> data;                        last -> next = ptr -> next;                        free(ptr->key);                        free(ptr);                        return data;                  }                  /*                  ** If 'last' still equals NULL, it means that we need to                  ** delete the first node in the list. This simply consists                  ** of putting our own 'next' pointer in the array holding                  ** the head of the list.  We then dispose of the current                  ** node as above.                  */                  else                  {                        data = ptr->data;                        (table->table)[val] = ptr->next;                        free(ptr->key);                        free(ptr);                        return data;                  }            }      }      /*      ** If we get here, it means we didn't find the item in the table.      ** Signal this by returning NULL.      */      return NULL;}/*** free_table iterates the table, calling this repeatedly to free** each individual node.  This, in turn, calls one or two other** functions - one to free the storage used for the key, the other** passes a pointer to the data back to a function defined by the user,** process the data as needed.*/static void free_node(char *key, void *data){      (void) data;      if (function)            function(del(key,the_table));      else  del(key,the_table);}/*** Frees a complete table by iterating over it and freeing each node.** the second parameter is the address of a function it will call with a** pointer to the data associated with each node.  This function is** responsible for freeing the data, or doing whatever is needed with** it.*/void free_table(hash_table *table, void (*func)(void *)){      function = func;      the_table = table;      enumerate( table, free_node);      free(table->table);      table->table = NULL;      table->size = 0;      the_table = NULL;      function = (void (*)(void *))NULL;}/*** Simply invokes the function given as the second parameter for each** node in the table, passing it the key and the associated data.*/void enumerate( hash_table *table, void (*func)(char *, void *)){      unsigned i;      bucket *temp;      for (i=0;i<table->size; i++)      {            if ((table->table)[i] != NULL)            {                  for (temp = (table->table)[i];                        NULL != temp;                        temp = temp -> next)                  {                        func(temp -> key, temp->data);                  }            }      }}#ifdef TEST#include <stdio.h>void printer(char *string, void *data){      printf("%s: %s\n", string, (char *)data);}int main(void){      hash_table table;      char *strings[] = {            "The first string",            "The second string",            "The third string",            "The fourth string",            "A much longer string than the rest in this example.",            "The last string",            NULL            };      char *junk[] = {            "The first data",            "The second data",            "The third data",            "The fourth data",            "The fifth datum",            "The sixth piece of data"            };      int i;      void *j;      construct_table(&table,200);      for (i = 0; NULL != strings[i]; i++ )            insert(strings[i], junk[i], &table);      for (i=0;NULL != strings[i];i++)      {            printf("\n");            enumerate(&table, printer);            del(strings[i],&table);      }      for (i=0;NULL != strings[i];i++)      {            j = lookup(strings[i], &table);            if (NULL == j)                  printf("\n'%s' is not in table",strings[i]);            else  printf("\nERROR: %s was deleted but is still in table.",                  strings[i]);      }      free_table(&table, NULL);      return 0;}#endif /* TEST */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品第一页第二页第三页| 亚洲地区一二三色| 一区二区三区四区不卡在线| 天堂va蜜桃一区二区三区漫画版| 粉嫩绯色av一区二区在线观看| 欧美日韩在线观看一区二区| 国产视频一区二区三区在线观看| 亚洲第一二三四区| 一本一道久久a久久精品综合蜜臀| 精品噜噜噜噜久久久久久久久试看| 亚洲欧美色图小说| 国产99一区视频免费| 日韩精品中午字幕| 五月天精品一区二区三区| 91亚洲国产成人精品一区二区三 | 亚洲日本乱码在线观看| 热久久国产精品| 欧美在线高清视频| 中文字幕一区二区三| 国产不卡免费视频| 久久亚洲精精品中文字幕早川悠里| 天天综合色天天| 欧美三级一区二区| 亚洲精品国产a久久久久久| 高潮精品一区videoshd| 久久久综合网站| 久久国产成人午夜av影院| 欧美日本一区二区三区四区| 一区二区三区国产豹纹内裤在线| 91网站最新网址| 亚洲三级在线观看| 91麻豆免费视频| 亚洲三级在线播放| 色综合久久精品| 一区二区三区免费网站| 在线观看91视频| 亚洲国产一区视频| 666欧美在线视频| 丝袜美腿亚洲色图| 欧美一区二区私人影院日本| 美女视频一区二区三区| 精品美女被调教视频大全网站| 精品亚洲国产成人av制服丝袜| 精品88久久久久88久久久| 国产精品影视天天线| 中文字幕欧美国产| 一本大道av一区二区在线播放| 亚洲国产一区二区在线播放| 欧美一卡在线观看| 国产精品 欧美精品| 中文字幕亚洲区| 欧美网站一区二区| 麻豆国产精品一区二区三区| 久久精品一区二区三区不卡牛牛| 成人高清在线视频| 午夜伊人狠狠久久| 精品国产亚洲一区二区三区在线观看| 国产乱码字幕精品高清av | 精品国产第一区二区三区观看体验| 蜜臀av一区二区| 国产亚洲污的网站| 91福利国产成人精品照片| 日韩国产欧美在线观看| 久久精品亚洲国产奇米99| 色域天天综合网| 日本一区中文字幕| 中文字幕+乱码+中文字幕一区| 欧洲视频一区二区| 韩国精品免费视频| 亚洲制服丝袜av| 久久久国产午夜精品| 在线观看av一区二区| 国产美女视频91| 亚洲亚洲人成综合网络| 久久夜色精品国产欧美乱极品| 一本色道久久综合亚洲aⅴ蜜桃 | 色偷偷久久人人79超碰人人澡| 日韩精品电影一区亚洲| 国产欧美1区2区3区| 欧美日韩免费观看一区二区三区 | 国产精品免费aⅴ片在线观看| 欧美老肥妇做.爰bbww视频| 粉嫩av亚洲一区二区图片| 丝袜美腿亚洲综合| 亚洲黄色片在线观看| 国产日韩精品一区二区三区| 欧美一级午夜免费电影| 在线精品亚洲一区二区不卡| 国产一区二区不卡在线| 婷婷中文字幕综合| 亚洲精品一二三| 国产精品美女久久久久aⅴ| 欧美mv日韩mv国产网站app| 在线欧美小视频| a级高清视频欧美日韩| 国产一区二区三区免费| 日本最新不卡在线| 午夜欧美视频在线观看| 亚洲伦理在线免费看| 国产精品久久久久7777按摩| 久久精品综合网| 26uuu亚洲婷婷狠狠天堂| 欧美一二区视频| 欧美高清视频不卡网| 91精品福利视频| 91一区在线观看| 91美女视频网站| 91丝袜美女网| 色香色香欲天天天影视综合网| 岛国精品在线观看| 国产91在线看| 成人听书哪个软件好| 成人中文字幕电影| 北岛玲一区二区三区四区| www.欧美色图| k8久久久一区二区三区 | 亚洲激情五月婷婷| 亚洲激情图片小说视频| 亚洲在线观看免费| 天天操天天综合网| 日韩高清欧美激情| 六月丁香婷婷色狠狠久久| 久草在线在线精品观看| 久久国产三级精品| 国产精品亚洲综合一区在线观看| 国产成人av资源| 97国产一区二区| 欧美中文字幕一区二区三区亚洲| 欧美色窝79yyyycom| 欧美一区二区三区视频在线| 欧美成人一级视频| 中文字幕精品综合| 一区二区三区在线免费观看| 日韩国产欧美在线播放| 国产乱码精品一品二品| 波多野结衣一区二区三区| 欧美亚洲动漫精品| 欧美成人艳星乳罩| 亚洲国产高清aⅴ视频| 亚洲国产视频一区二区| 蜜臀精品一区二区三区在线观看| 国产99久久久精品| 欧美裸体bbwbbwbbw| 精品福利av导航| 亚洲人成7777| 美女尤物国产一区| 91论坛在线播放| 日韩欧美国产系列| 亚洲视频免费看| 蜜桃在线一区二区三区| 国产aⅴ综合色| 欧美另类高清zo欧美| 国产欧美日韩在线视频| 亚洲成人免费影院| 成人免费高清在线观看| 欧美精品乱码久久久久久按摩 | 欧美电视剧免费全集观看| 国产欧美精品一区二区三区四区| 一区二区三区欧美日韩| 韩国成人精品a∨在线观看| 91国在线观看| 久久亚洲春色中文字幕久久久| 一区二区三区资源| 国内精品免费在线观看| 欧美三级电影网站| 国产精品热久久久久夜色精品三区| 日韩影院在线观看| 成人免费不卡视频| 精品嫩草影院久久| 偷偷要91色婷婷| 精品国产精品网麻豆系列| 亚洲精品视频自拍| 国产成人av电影在线| 日韩欧美国产精品| 亚洲福利一二三区| av不卡免费在线观看| 欧美精品一区男女天堂| 亚洲va欧美va天堂v国产综合| gogogo免费视频观看亚洲一| 26uuu色噜噜精品一区| 美国毛片一区二区三区| 欧美日韩精品一区二区| 亚洲欧美视频一区| 色综合天天综合网天天看片| 国产精品青草综合久久久久99| 国产真实乱对白精彩久久| 欧美一区午夜视频在线观看| 亚洲一二三区视频在线观看| 色欧美88888久久久久久影院| 中文字幕av在线一区二区三区| 国产露脸91国语对白| 精品剧情在线观看| 久久草av在线| 精品国产欧美一区二区| 韩国中文字幕2020精品| 久久精品欧美一区二区三区不卡| 韩国女主播成人在线| 国产亚洲精品精华液| 国产成人午夜高潮毛片| 国产欧美日韩激情|