• <sub id="h4knl"><ol id="h4knl"></ol></sub>
    <sup id="h4knl"></sup>
      <sub id="h4knl"></sub>

      <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
      1. <strong id="h4knl"></strong>

      2. 深入PHP中的HashTable結(jié)構(gòu)詳解

        時(shí)間:2024-07-01 21:50:41 PHP 我要投稿
        • 相關(guān)推薦

        深入PHP中的HashTable結(jié)構(gòu)詳解

          深入PHP中的HashTable結(jié)構(gòu)詳解

          對php內(nèi)核有一定了解的人應(yīng)該都知道php的精髓就是HashTable,HashTable在php的實(shí)現(xiàn)中無處不在。包括php的數(shù)組、什么全局變量、局部變量的作用域等等,php的hashtable拆開來說就是四部分:

          hash函數(shù):用的是time33的散列函數(shù),將一個(gè)字符串的'key轉(zhuǎn)換成一個(gè)數(shù)字

          一個(gè)C數(shù)組:用來儲(chǔ)存桶(buckets)的

          兩個(gè)雙向的鏈表:第一個(gè)雙向鏈表是數(shù)組的每個(gè)元素(桶bucket)是一個(gè)雙向鏈表,這樣做是為了解決hash沖突;第二個(gè)雙向鏈表是數(shù)組將每一個(gè)桶(bucket)連接起來,這里要連接的也就是第一個(gè)雙向鏈表的鏈表頭,這樣做是為了遍歷整個(gè)hash表用的,鳥哥有篇blog是講php的foreach的,這里這樣設(shè)計(jì)就是給foreach用的==>《深入理解PHP之?dāng)?shù)組(遍歷順序)》

          我這里不再說hashtable的struct和bucket的struct了,因?yàn)橄旅娴耐扑]鏈接幾乎都講了,我不覺得我能描述和說的比他們好,每個(gè)人的水平不一樣,我就以我現(xiàn)在的技術(shù)水平來描述,所以我就只把我整理的一些東西記錄一下

          下面是php中hash實(shí)現(xiàn)的兩個(gè)文件:zend_hash.c zend_hash.h。這兩個(gè)文件里面實(shí)現(xiàn)了一堆的api,也引申出了一堆的api,下面是實(shí)現(xiàn)出來的api的原型

          復(fù)制代碼 代碼如下:

          ZEND_API ulong zend_hash_func(const char *arKey, uint nKeyLength)

          ZEND_API ulong zend_get_hash_value(const char *arKey, uint nKeyLength)

          ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)

          ZEND_API void zend_hash_set_apply_protection(HashTable *ht, zend_bool bApplyProtection)

          ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)

          ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, const char *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)

          ZEND_API int _zend_hash_index_update_or_next_(HashTable *ht, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)

          ZEND_API int zend_hash_rehash(HashTable *ht)

          static int zend_hash_do_resize(HashTable *ht)

          ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, uint nKeyLength, ulong h, int flag)

          ZEND_API void zend_hash_destroy(HashTable *ht)

          ZEND_API void zend_hash_clean(HashTable *ht)

          static Bucket *zend_hash_apply_r(HashTable *ht, Bucket *p)

          ZEND_API void zend_hash_graceful_destroy(HashTable *ht)

          ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht)

          ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC)

          ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *argument TSRMLS_DC)

          ZEND_API void zend_hash_apply_with_arguments(HashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int num_args, …)

          ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC)

          ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size)

          ZEND_API void _zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, int overwrite ZEND_FILE_LINE_DC)

          static zend_bool zend_hash_replace_checker_wrapper(HashTable *target, void *source_data, Bucket *p, void *pParam, merge_checker_func_t merge_checker_func)

          ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, uint size, merge_checker_func_t pMergeSource, void *pParam)

          ZEND_API int zend_hash_find(const HashTable *ht, const char *arKey, uint nKeyLength, void **pData)

          ZEND_API int zend_hash_quick_find(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h, void **pData)

          ZEND_API int zend_hash_exists(const HashTable *ht, const char *arKey, uint nKeyLength)

          ZEND_API int zend_hash_quick_exists(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h)

          ZEND_API int zend_hash_index_find(const HashTable *ht, ulong h, void **pData)

          ZEND_API int zend_hash_index_exists(const HashTable *ht, ulong h)

          ZEND_API int zend_hash_num_elements(const HashTable *ht)

          ZEND_API int zend_hash_get_pointer(const HashTable *ht, HashPointer *ptr)

          ZEND_API int zend_hash_set_pointer(HashTable *ht, const HashPointer *ptr)

          ZEND_API void zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos)

          ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos)

          ZEND_API int zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos)

          ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos)

          ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, char **str_index, uint *str_length, ulong *num_index, zend_bool duplicate, HashPosition *pos)

          ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos)

          ZEND_API int zend_hash_get_current_data_ex(HashTable *ht, void **pData, HashPosition *pos)

          ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, const char *str_index, uint str_length, ulong num_index, int mode, HashPosition *pos)

          ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func, compare_func_t compar, int renumber TSRMLS_DC)

          ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC)

          ZEND_API int zend_hash_minmax(const HashTable *ht, compare_func_t compar, int flag, void **pData TSRMLS_DC)

          ZEND_API ulong zend_hash_next_free_element(const HashTable *ht)

          void zend_hash_display_pListTail(const HashTable *ht)

          void zend_hash_display(const HashTable *ht)

        《&.doc》
        将本文的Word文档下载到电脑,方便收藏和打印
        推荐度:
        点击下载文档

        【深入PHP中的HashTable結(jié)構(gòu)詳解】相關(guān)文章:

        關(guān)于深入PHP內(nèi)存相關(guān)的功能特性詳解09-02

        php多進(jìn)程編程詳解201706-04

        PHP中curl的使用實(shí)例07-31

        英語基本語法結(jié)構(gòu)詳解10-25

        PHP中關(guān)于類的定義10-02

        linux操作系統(tǒng)目錄結(jié)構(gòu)詳解07-17

        GRE考試難句語法結(jié)構(gòu)詳解01-22

        PHP中函數(shù)的使用說明09-01

        PHP中的排序函數(shù)區(qū)別分析08-23

        教育碩士輔導(dǎo)之詳解教育的結(jié)構(gòu)與功能12-03

        在线咨询
        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码
      3. <sub id="h4knl"><ol id="h4knl"></ol></sub>
        <sup id="h4knl"></sup>
          <sub id="h4knl"></sub>

          <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
          1. <strong id="h4knl"></strong>

          2. 一区二区三区四区不长视频 | 最新成免费人久久精品 | 最新国产99热这里只有精品 | 午夜麻豆国产精品 | 亚洲日本电影久久 | 中文专区欧美三级在线 |

            深入PHP中的HashTable結(jié)構(gòu)詳解

              深入PHP中的HashTable結(jié)構(gòu)詳解

              對php內(nèi)核有一定了解的人應(yīng)該都知道php的精髓就是HashTable,HashTable在php的實(shí)現(xiàn)中無處不在。包括php的數(shù)組、什么全局變量、局部變量的作用域等等,php的hashtable拆開來說就是四部分:

              hash函數(shù):用的是time33的散列函數(shù),將一個(gè)字符串的'key轉(zhuǎn)換成一個(gè)數(shù)字

              一個(gè)C數(shù)組:用來儲(chǔ)存桶(buckets)的

              兩個(gè)雙向的鏈表:第一個(gè)雙向鏈表是數(shù)組的每個(gè)元素(桶bucket)是一個(gè)雙向鏈表,這樣做是為了解決hash沖突;第二個(gè)雙向鏈表是數(shù)組將每一個(gè)桶(bucket)連接起來,這里要連接的也就是第一個(gè)雙向鏈表的鏈表頭,這樣做是為了遍歷整個(gè)hash表用的,鳥哥有篇blog是講php的foreach的,這里這樣設(shè)計(jì)就是給foreach用的==>《深入理解PHP之?dāng)?shù)組(遍歷順序)》

              我這里不再說hashtable的struct和bucket的struct了,因?yàn)橄旅娴耐扑]鏈接幾乎都講了,我不覺得我能描述和說的比他們好,每個(gè)人的水平不一樣,我就以我現(xiàn)在的技術(shù)水平來描述,所以我就只把我整理的一些東西記錄一下

              下面是php中hash實(shí)現(xiàn)的兩個(gè)文件:zend_hash.c zend_hash.h。這兩個(gè)文件里面實(shí)現(xiàn)了一堆的api,也引申出了一堆的api,下面是實(shí)現(xiàn)出來的api的原型

              復(fù)制代碼 代碼如下:

              ZEND_API ulong zend_hash_func(const char *arKey, uint nKeyLength)

              ZEND_API ulong zend_get_hash_value(const char *arKey, uint nKeyLength)

              ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)

              ZEND_API void zend_hash_set_apply_protection(HashTable *ht, zend_bool bApplyProtection)

              ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)

              ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, const char *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)

              ZEND_API int _zend_hash_index_update_or_next_(HashTable *ht, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)

              ZEND_API int zend_hash_rehash(HashTable *ht)

              static int zend_hash_do_resize(HashTable *ht)

              ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, uint nKeyLength, ulong h, int flag)

              ZEND_API void zend_hash_destroy(HashTable *ht)

              ZEND_API void zend_hash_clean(HashTable *ht)

              static Bucket *zend_hash_apply_r(HashTable *ht, Bucket *p)

              ZEND_API void zend_hash_graceful_destroy(HashTable *ht)

              ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht)

              ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC)

              ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *argument TSRMLS_DC)

              ZEND_API void zend_hash_apply_with_arguments(HashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int num_args, …)

              ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC)

              ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size)

              ZEND_API void _zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, int overwrite ZEND_FILE_LINE_DC)

              static zend_bool zend_hash_replace_checker_wrapper(HashTable *target, void *source_data, Bucket *p, void *pParam, merge_checker_func_t merge_checker_func)

              ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, uint size, merge_checker_func_t pMergeSource, void *pParam)

              ZEND_API int zend_hash_find(const HashTable *ht, const char *arKey, uint nKeyLength, void **pData)

              ZEND_API int zend_hash_quick_find(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h, void **pData)

              ZEND_API int zend_hash_exists(const HashTable *ht, const char *arKey, uint nKeyLength)

              ZEND_API int zend_hash_quick_exists(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h)

              ZEND_API int zend_hash_index_find(const HashTable *ht, ulong h, void **pData)

              ZEND_API int zend_hash_index_exists(const HashTable *ht, ulong h)

              ZEND_API int zend_hash_num_elements(const HashTable *ht)

              ZEND_API int zend_hash_get_pointer(const HashTable *ht, HashPointer *ptr)

              ZEND_API int zend_hash_set_pointer(HashTable *ht, const HashPointer *ptr)

              ZEND_API void zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos)

              ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos)

              ZEND_API int zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos)

              ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos)

              ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, char **str_index, uint *str_length, ulong *num_index, zend_bool duplicate, HashPosition *pos)

              ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos)

              ZEND_API int zend_hash_get_current_data_ex(HashTable *ht, void **pData, HashPosition *pos)

              ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, const char *str_index, uint str_length, ulong num_index, int mode, HashPosition *pos)

              ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func, compare_func_t compar, int renumber TSRMLS_DC)

              ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC)

              ZEND_API int zend_hash_minmax(const HashTable *ht, compare_func_t compar, int flag, void **pData TSRMLS_DC)

              ZEND_API ulong zend_hash_next_free_element(const HashTable *ht)

              void zend_hash_display_pListTail(const HashTable *ht)

              void zend_hash_display(const HashTable *ht)